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:
instantiating a struct variable:
accessing struct atributes:
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.
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
}
Code:
var s = foo{ "stuff", 54, c_blue };
Code:
var name = s.name;
var size = s.size;
s.colour = c_red;
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.