Update 'Variable Definition and Type Notation'
parent
f1e469df53
commit
2e8c99764f
13
Variable-Definition-and-Type-Notation.md
Normal file
13
Variable-Definition-and-Type-Notation.md
Normal file
@ -0,0 +1,13 @@
|
||||
In ARF, variables are defined using the syntax `name:Type:qualifier`, where name
|
||||
is a name token and type is either just a name token describing what type it is,
|
||||
or a pointer to a value of that type or an array to a value of that type. The
|
||||
only supported qualifier is `:mut`, which marks the variable's data as mutable.
|
||||
Variables are immutable by default.
|
||||
|
||||
Pointers are defined like `name:{Type}` and arrays are defined like
|
||||
`name:{Type length}` where length is an unsigned integer literal or an ellipsis
|
||||
token (..). If an integer token is given, the length of the array is static, and
|
||||
if an ellipsis is given, the length is dynamic and can be changed at runtime.
|
||||
|
||||
Variables can be defined wherever they are used. For example, `set x:Int 5`
|
||||
defines a variable of type Int and sets it to 5.
|
Reference in New Issue
Block a user