sonolus.script.values¶
alloc(type_: type[T]) -> T
¶
Return an uninitialized instance of the given type.
Use this carefully as reading from uninitialized memory can lead to unexpected behavior.
copy(value: T) -> T
¶
Make a deep copy of the given value.
Generally works the same as the unary + operator on records and arrays.
freeze(value: T) -> T
¶
Return a read-only version of the given value.
If the original value is modified, no guarantees are made about behavior and changes may or may not be reflected in the frozen version. Use freeze(copy(value)) to guarantee independence.
sizeof(type_: type) -> int
¶
Return the size of the given type.
swap(a: T, b: T)
¶
Swap the values of the two provided mutable values.
Only supported for values of a reference type such as Array or Record, which support the copy-from operator
(@=) this relies on. Num values do not support @= and cannot be swapped with this function.
zeros(type_: type[T]) -> T
¶
Make a new instance of the given type initialized with zeros.
Generally works the same as the unary + operator on record and array types.