-
Notifications
You must be signed in to change notification settings - Fork 260
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
[SUGGESTION] Independent order and type data members #406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
There's also no order independence in a type's Cpp1 declaration (template parameters and requires clause).
|
Here is the order of emitted Cpp1
That results in these order dependencies:
|
See the last paragraph of #75 (comment). |
@hsutter What do you think about Right now, a |
This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
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 beforeS
declarationThe text was updated successfully, but these errors were encountered: