The Question As Old As Time - Structs Within Structs

Started by monkey0506, Fri 14/07/2006 08:43:25

Previous topic - Next topic

monkey0506

It's been asked a billion times over, and CJ has said several times he would consider it for a future version of AGS. It has plagued the nightmares of wanna-be adventure game makers for years. And the question is this:

When will AGS support structs within structs?

I understand CJ has said that he will implement it, but the question remains, when? CJ has a lot of bugs and suggestions to implement, but it seems this isn't even on the tracker?

As for the forum I'm putting this in, the question doesn't seem very technical any more as it is not a question of "can it be implemented", just rather a question of how high a priority it is and how soon one could expect to see it.

Tonight I was working on an old project of mine when I realized I can't put a vector as a data member of a struct...:D. Now it could be worked around in this case...but it makes it a lot more difficult.

In any case, I'd like to say that I appreciate all CJ has done in making AGS the best game engine available.

scotch

Structs within structs would be nice, but to me perhaps an even more interesting thing would be if struct definitions actually define a new kind of AGS Managed Object that can be constructed at runtime, pointed at with pointers, and passed around by reference, just like Strings (Which is a pointer type, regardless of having no * after it). That'd make heavy AGS scripting so much easier, to me. With this, even if you couldn't have structs within structs, you could presumably still have a MyStruct* in there, and initialise it in the constructor.

In most languages you're passing by reference much much more than by value, because it's both more efficient and it makes a lot of programming patterns possible that otherwise wouldn't be. In fact lots of languages simply don't have pass by value.

Gilbert

In my opionion I think if this is going to be implemented, multi-dimensional arrays should go first, but if they're done at the same time, it'd of course be great.



No, actually I don't even need either of these features.

monkey0506

Quote from: scotch on Fri 14/07/2006 08:59:26Which is a pointer type, regardless of having no * after it

Code: ags
internalstring autoptr managed struct String {


It's automagically a pointer!

And I like the rest of your idea...however it seems that it would be much more difficult to implement (I actually have no idea, just taking a stab in the dark)...

And I see no reason for multidimensional arrays to come first. Those are at least easy to work around. :=

Radiant

Quote from: monkey_05_06 on Fri 14/07/2006 08:43:25
It's been asked a billion times over, and CJ has said several times he would consider it for a future version of AGS. It has plagued the nightmares of wanna-be adventure game makers for years. And the question is this:
You definitely need some time off coding AGI or Z-code :)


monkey0506

#6
Hmm...it would seem that this doesn't work:

Code: ags
managed struct A {
  int Item;
  };

struct B extends A {
  import void Copy(A* a);
  };

void B::Copy(A* a) {
  this.Item = a.Item;
  }


Compiles fine, just when you actually try to use the function it fails...Something about the object being pointed to not being in the managed object pool... :-\


Hheheheh...Another failed workaround. Must be time for implementation :D

Just kidding. I know CJ's busy with other stuff. And yeah, he probably does deserve a break, but I imagine if he didn't like doing it then he probably wouldn't.

MillsJROSS

QuoteAnd I see no reason for multidimensional arrays to come first. Those are at least easy to work around. Larry Values!!11

They also should be easier to implement within the engine, and while yes it's easy enough to simulate multi-dimensional arrays, I think you have to focus on the small things before the bigger things. Also, I feel multi-dimensional arrays have more likely hood of being used more often then structs within structs. Also, because AGS is designed for adventure games, inheritance isn't usually needed as often as it would be in other genres. Not that the implementation of this wouldn't be helpful.

-MillsJROSS

Radiant

AGS might not really support multidim arrays, but then neither does C. You can easily implement them using singledim arrays, like this:

x = array[a];
x = array[a + ROWLEN * b];

(or write a small function array(a,b) that does the same).

Gilbert

Everybodies know that. but being able to have it natively with the engine is nice.

SMF spam blocked by CleanTalk