Skip to content

[SUGGESTION] Independent order and type data members #406

Closed
@realgdman

Description

@realgdman

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions