Description
I haven't found a way to aggregate initialize struct.
Background: I'm working with Entity-Component-System. It supposes to have many POD structs. Writing constructor in each is cumbersome.
In C++ they could be simply initialized with S s { 1, 7 };
I don't know if I missed correct syntax or it is intended, or is it bug.
S : @struct type = {
public x : int;
public y : float;
}
main: () = {
//s1: S = (1, 2); //cpp2 Ok, cpp1 no matching ctor S s1 {1, 2};
//s2: S;
//s2 = (1, 2); //cpp2 Ok, cpp1 no matching ctor s2.construct(1,2);
}
foo: (inout s3 : S) = {
//s3 = (1, 2); //cpp2 Ok, cpp1 no viable overloaded = s3 = 1, 2;
//s4 = ((1, 2)); //cpp2 Ok, cpp1 no viable overloaded = s4 = 1, 2;
//s5 = (.x=1, .y=2); //I know named not in cpp2 yet
//s6 = {1, 2}; //cpp2 ill formed initializer at {
//also tried for fun s7 = (copy (1, 2) - it emits cpp1 copy(1,2)
}`
If it is intended to not have aggregate init, it would be good to have some meta facility, like one autogenerated constructor, which have as parameters all data members in order.