Description
Independent order of declaration works for functions, because definitions of those functions put after declarations of variables.
However, declarations of types can intertwine with variables, so data members not always can refer those globals.
Code Example
S: type = {
mi: int = i; //cpp1 error - undeclared i
pi: * int = i&; //cpp1 error - undeclared i
f: () = std::cout << i; //ok, function definition pushed down
}
main: () = {
li:= i; //ok, function definition pushed down
std::cout << i; //ok
}
i: int = 42;
Additional note
Probably hard to solve, requiring some sort of dependency graph
Namespaces doesn't seem to help here, because namespace itself still may be placed after class declaration.
In this case workaround is simple - move i: int = 42;
declaration before S
declaration