Structs allow to access individual members in a data structure.

Structs are defined by rolling back the program address with |00, similarly to how you would define an enum.

|00 @person &name $2 &age $1 &height $2 &length

The length member of the struct holds the total size of the struct, and allows to jump to a specific item in a datastructure.


The idea here is that you define padded labels, for example the ;person/age label holds the value of $0002, naming that offset allows to access specific members of a data structure by applying the sublabels of the enum to a pointer.

|0100 @reset

	( get second person ) ;family #0001 ;person/length MUL2 ADD2
		( get name* ) DUP2 ;person/name ADD2 LDA2 print-string
		( get age ) DUP2 ;person/age ADD2 LDA print-byte
		( get height* ) ;person/height ADD2 LDA2 print-short


@family ( name* age height* )
	=dict/melany 2a 008c
	=dict/emily 14 0073
	=dict/avery 09 0091

	&melany "Melany $1
	&emily "Emily $1
	&avery "Avery $1