Value Types¶
The following primitive value types are supported natively.
Category | type_of() | to_string() |
---|---|---|
System integer | "i32" or "i64" | "42" , "123" etc. |
Other integer number | "i32" , "u64" etc. | "42" , "123" etc. |
Integer numeric range | "range" , "range=" | "2..7" , "0..=15" etc. |
Floating-point number | "f32" or "f64" | "123.4567" etc. |
Fixed precision decimal number | "decimal" | "42" , "123.4567" etc. |
Boolean value | "bool" | "true" or "false" |
Unicode character | "char" | "A" , "x" etc. |
Immutable Unicode string | "string" | "hello" etc. |
Array | "array" | "[ 1, 2, 3 ]" etc. |
Byte array – BLOB | "blob" | "[01020304abcd]" etc. |
Object map | "map" | "#{ "a": 1, "b": true }" etc. |
Timestamp | "timestamp" | "<timestamp>" |
Function pointer | "Fn" | "Fn(foo)" etc. |
Dynamic value (i.e. can be anything) | the actual type | actual value |
Shared value (a reference-counted, shared dynamic value, created via closures | the actual type | actual value |
Nothing/void/nil/null/Unit (or whatever it is called) | "()" | "" (empty string) |
All types are treated strictly distinct by AviScript, meaning that i32
and i64
and u32
are completely different. They cannot even be added together.
This is very similar to Rust.
strings in AviScript are immutable, meaning that they can be shared but not modified.
Any modification done to a AviScript string causes the string to be cloned and the modifications made to the copy.
The to_string
function converts a standard type into a string for display purposes.
The to_debug
function converts a standard type into a string in debug format.