Built-in Procedures
Built-in procedures are predeclared. They are called like any other procedure but some of them accept a type rather than an expression as their first argument.
Built-in procedures do not have standard types and cannot be passed around like a normal procedure.
Length and capacity
The built-in procedures len
and cap
take arguments of various types and return a result of type int
or untyped int (if the value is constant). It is guaranteed that the value will fit into int
.
Both of these procedures allow a point to the argument type too.
Call Argument type Result
len(s) string type string length in bytes
[N]T array length (== N)
[vector N]T vector length (== N)
[]T slice length
[dynamic]T dynamic array length
map[K]T number of defined keys
cap(s) [N]T array length (== N)
[]T slice capacity
[dynamic]T dynamic array capacity
map[K]T capacity of values
The capacity of a slice and dynamic array is the number of elements for which there is space allocated for the underlying array. At any time, the following relation holds:
0 <= len(s) <= cap(s)
The length or capacity of a nil
slice, dynamic array or map is 0
.
If the expression is constant, the length and/or capacity will be a constant untyped integer.
Allocations
new
and free
and make
len, cap
make
size_of, align_of, offset_of
type_of, type_info_of
compile_assert
swizzle,
complex, quaternion
real, imag, jmag, kmag
conj
expand_to_tuple
min, max, abs, clamp
transmute