Structures¶
A STRUCT is a value type with fields, member functions, and nested
declarations:
::point STRUCT
{
.x VAR I32;
.y VAR I32;
.CONSTRUCTOR FUNCTION(@x I32, @y I32)
{
.x := x;
.y := y;
}
.sum FUNCTION() CONST: I32
{
RETURN .x + .y;
}
::origin FUNCTION(): point
{
RETURN point(@x 0, @y 0);
}
}
.x,.y, and.sumare instance members..xin a member body is shorthand for the member ofTHIS.::originis nested inpointbut receives no object.
Public field reflection¶
Public Field Reflection provides field counts,
names, declared types, and access by compile-time name or index through
PUBLIC_FIELD_*. Only directly declared public instance fields are included,
in declaration order. Private and inherited fields are excluded.
Receiver qualifiers¶
A member function may place MUT, CONST, WRITE, or TEMP after its
parameter list:
The suffix reuses the ordinary parameter model. FUNCTION() CONST is
semantically the same receiver form as an explicit
@THIS CONST& THISTYPE parameter, while keeping the common member spelling
compact. THIS names the current object and THISTYPE names its formal owner
type.
Struct modifiers¶
Modifiers appear between STRUCT and its body. The current set includes
MOVE_ONLY, NOT_COPYABLE, NO_IMPLICIT_DEFAULT_CONSTRUCTOR,
NO_IMPLICIT_CONSTRUCTORS, NO_IMPLICIT_ASSIGNMENT, NO_IMPLICIT_COPY,
ANTESTATAL, SERIALOID, NONSTATIC, STRINGLIKE, POLYMORPHIC,
VIRTUAL_POLYMORPHIC, and FINAL.
The modifiers constrain generated special functions or declare specialized
static/serialization contracts. See
Constructors and destructors,
Inheritance,
STATIC Compile-Time Constants,
and Serialization.
IBC_STRUCT¶
An ordinary STRUCT may reorder fields to optimize layout. IBC_STRUCT
preserves C-compatible field order and padding for external layouts:
IBC_STRUCT provides the C-compatible layout required at a binary boundary.
Internal layout preferences do not require IBC_STRUCT.
Composites provide anonymous structural record types with inferred fields and ordinary struct lifetime semantics. Their field names and types participate in structural identity and static reflection.
Relocation permission¶
TRIVIALLY_RELOCATABLE and TRIVIALLY_RELOCATABLE_IF(condition) authorize
compiler-owned lifetime transfer. See Trivial Relocation
for the invariant and destruction contract.