Types
| Type | Description |
|---|---|
bool |
true / false |
int |
signed 64-bit; wraps on overflow |
float |
IEEE float32 |
string |
immutable UTF-8; + concatenation, comparison, len in bytes; no indexing |
Vec2 Vec3 Color Quat Rect |
engine value types; lanes .X .Y .Z .W, .R .G .B .A, .X .Y .W .H |
Transform2D{Position Vec2, Rotation float, Scale Vec2} |
value struct |
Transform3D{Position Vec3, Rotation Quat, Scale Vec3} |
value struct |
NodeRef |
reference to a node; may be nil |
AssetRef<Texture | Scene | Prefab | Mesh> |
reference to an asset; may be nil |
ComponentRef<T> |
reference to a component on a node; may be nil |
ScriptRef<T> |
reference to an instance of script T; may be nil; fields, plain methods and signals of T |
Coroutine |
handle returned by start; may be nil; methods Stop(), Running() bool |
Connection |
handle returned by Connect; may be nil; methods Disconnect(), Connected() bool |
struct |
package-level, value semantics, copied on assignment |
enum |
package-level, int-backed, members State.Idle |
[]T |
growable slice on the VM heap |
Rules:
- No implicit numeric conversion. Use
int(x),float(x),string(x)(frombool,int,float,string),int(e)for an enum andState(i)for int → enum. Untyped constants adapt to the context (var f float = 1is fine,var i int = 1.5is not). floatarithmetic is float32 everywhere, including constant folding.==/!=work on scalars, strings, enums, references, handles, vectors, structs with comparable fields, andTransform*;Quatand slices are not comparable.< <= > >=work on numbers and strings.- Vector arithmetic:
v + w,v - w,v * s,s * v,v / s,-v; vectors are constructed only with composite literals (Vec2{x, y},Color{1, 0, 0, 1}), never with call syntax. - A struct is a value:
a = bcopies; passing to a function copies. Nested structs are allowed, including structs from other packages; a struct that contains itself by value isAES2017. - A slice element may occupy at most 32 value slots (
AES2032); scalars, vectors, refs and small structs are far below it. nilis valid for the six reference and handle typesNodeRef,AssetRef,ComponentRef,ScriptRef,CoroutineandConnection. Reading or writing through a nil reference is a runtime fault (AES6004); calling a method on a nilCoroutineorConnectionis not:Running()andConnected()returnfalse,Stop()andDisconnect()do nothing.