[SUGGESTION] Independent order and type data members #641
realgdman
started this conversation in
Suggestions
Replies: 4 comments
|
There's also no order independence in a type's Cpp1 declaration (template parameters and requires clause). |
0 replies
|
Here is the order of emitted Cpp1
That results in these order dependencies:
|
0 replies
See the last paragraph of #75 (comment). |
0 replies
|
@hsutter What do you think about Right now, a |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
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 ipi: * int = i&; //cpp1 error - undeclared if: () = std::cout << i; //ok, function definition pushed down}main: () = {li:= i; //ok, function definition pushed downstd::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 beforeSdeclarationAll reactions