Variables
Variables store various kinds of data.
Global Variables
Global variables are constructed from constant expressions at compile time.
Text: "I am a global variable"
Mutability
By default, global variables are not mutable.
To modify a variable after declaration, it must be declared with mut
.
Greeting :mut "Hello"
Greeting = "Aloha"
Local Variables
Local variables are only accessible from their function, but may have different values between function calls.
Explicit assignment =
differentiates local variables from globals.
Index :natural = 0
Dynamic Types
By default, variables are defined with an assigned type and cannot accept data of other types. The dynamic type constructor produces a local variable that accepts any data.
Any := 5
Any = "test"
(future) A global variable may be defined as dynamic using the dyn
expression.
A variable declared with dyn is automatically mutable.
Any :dyn "change me"
Type Aliases
The type alias construction produces a constant, global variable storing a specified type.
Numbers :: list{natural}
To store mutable types, use the local variable construction.
Numbers :type = list{natural}