Re: Phix : nested structs
- Posted by petelomax 1 week ago
- 149 views
Seems about right. If you store a struct in an array (inherently of possibly mixed types),
the compiler does not know that array[i] is a struct until you store it in an appropriately typed variable.
I remember something like "sequence of Camera2D" being on someone's RDS Eu wish list long before Phix was even born.
Structs are just a collection of fields, with atom/bool/string/sequence/struct|object defaulting to 0/false/""/{}/NULL.
Hence offset and target will be NULL unless you explicitly create new Vector2 for them. This should also work:
for i=1 to MAX do array[i]=new(Camera2D,{new(Vector2,{i,i*i}),new(Vector2)}) end for
I'm not going to try and pretend the Phix implementation of structs is particularly wonderful.
I should probably say structs/classes most likely wont be in Phix v2.0, if ever released, though v1.x won't suddenly vanish.

