• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

 suggestion: Structs

Status
Not open for further replies.

GMWolf

aka fel666
I know many people have already asked for structs. And that YYG have already said its on their wish list, but i beleive noone has made a suggestion as to how they should actually work. so here goes:

Rather than having a new data type per struct, A single new data type could be added: struct. This would hold the values of the struct, aswell as the type of struct it is. All structs variables would be of type struct.

defining a struct could be done in a simmilar way to enums:
Code:
struct foo {
    name,
    size,
    colour
}
instantiating a struct variable:
Code:
var s = foo{ "stuff", 54, c_blue };
accessing struct atributes:
Code:
var name = s.name;
var size = s.size;
s.colour = c_red;
All checks could be done at runtime:
Checking if the variable is a struct. (simmilar to how arrays are checked at runtime)
Checking if the struct's type has a the specified field.

structs could essentially be represented like a GM-array, with each field name being the index in the array. simmilar to how we currently pair enums and arrays to emulate structs.
 

Mike

nobody important
GMC Elder
I'm not going to start another massive thread on something we've all said we want, and we will do if/when we can.
 
Status
Not open for further replies.
Top