We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
A global object is declared at module level with some fields:
~ foo { a: f64 } fn bar() foo { println(foo.a) } fn baz() mut foo { foo.a = 42 }
The global object is created automatically if it doesn't exist already. A global object outlives any other lifetime.
The globals function returns a list of all global objects:
globals
fn main() { println(globals()) }
A global can be destroyed, but it will recreated when calling some function accessing it or using it:
fn main() { foo() // Creates global object `foo_object` destroy("foo") foo() // Recreates global object `foo_object` } ~ foo_object {} fn foo() foo_object {}
A global object can inherit from another global object:
~ rect { pos: [vec4], size: [vec4] } ~ button: rect { label: [str] }
When a global object only contains arrays as members, one can use the for-in syntax:
fn foo() mut button { for b in button { b.label = "click me!" } }
Methods can be declared on global objects that can be used inside for-in syntax:
~ rect { pos: [vec4], size: [vec4], min() = pos max() = pos + size } fn foo() rect { for r in rect { println(r.max()) } }
Methods can also combine lists and scalar fields:
~ foo { a: f64, b: [f64], bar() = a + b }
To insert a new item in a global object, one uses push syntax:
push
~ rect { pos: vec4, size: vec4 } fn main() { foo() } fn foo() mut rect { push rect { pos: (0, 0), size: (0, 0) } }
The super function returns the inherited global object of a global object:
super
fn super(global: str) -> opt[str] { ... }
The methods function returns a list of methods and their types:
methods
fn methods(global: str) -> [{}] { ... }
The glob function converts a global into an ordinary object (read-only):
glob
fn glob(global: str) -> opt[{}] { ... }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
A global object is declared at module level with some fields:
The global object is created automatically if it doesn't exist already.
A global object outlives any other lifetime.
The
globals
function returns a list of all global objects:A global can be destroyed, but it will recreated when calling some function accessing it or using it:
A global object can inherit from another global object:
When a global object only contains arrays as members, one can use the for-in syntax:
Methods can be declared on global objects that can be used inside for-in syntax:
Methods can also combine lists and scalar fields:
To insert a new item in a global object, one uses
push
syntax:The
super
function returns the inherited global object of a global object:The
methods
function returns a list of methods and their types:The
glob
function converts a global into an ordinary object (read-only):The text was updated successfully, but these errors were encountered: