Special functions
Special functions are defined with a fun
keyword and cannot be invoked directly.
get
let v = map[k]
Indexer getter.
set
map[k] = v
Indexer setter.
get_ptr
if array[i].is_occupied then
...
Indexer getter that returns a pointer instead of an element itself. Is used to invoke struct methods and access fields.
get_mut_ptr
array[i].is_occupied = true
Same as get_ptr
, but the resulting pointer is mutable.
hash
Calculates a hash and writes the result to state
.
fun hash<T> (list : List<T>) (state : HashState) =
for i = 0 until list.size do
hash@ list[i] state
hash@
invokes a hash function for the first argument.
let value = list@hash
Modifier @hash
returns an actual hash value.
to_string
Converts a value into a string.
from_slice
fun from_slice<T> (slice : Slice<T>) : List<T> = List<T>.from slice
def list_of<T> (list : List<T> @vararg) = list
When list_of
is called, it receives a slice of an array of arguments, converted to a List
using the from_slice
function.
destruct
Destructor is invoked before memory is freed. Can be used to make sure no weak references are pointing at an object, for example a container can clear the parent
field of its items.