Address-based non-owning wrapper that reconstructs one referenced value through one schema-supplier helper.
Typical construction forms differ only by the mutability of the schema supplier closure.
myRef: @getSchema Mref; # mutable result from CALL
myRef: [getSchema Cref] Mref; # immutable result from CALL
getSchema is one helper that returns one representative value or reference of the required schema.
data stores one address as Natx.CALL reconstructs the referenced value from that address through getSchema and addressToReference.set replaces only the stored address. The wrapper does not copy or own the target object.CALL |
(-- ref) |
Reconstructs the current referenced value from the stored address. |
getSchema.SCHEMA_NAME: reported schema name, "Mref".getSchema: helper used to reconstruct the target schema.data: stored address as Natx."Mref" use
"control" use
Int32Schema: [0];
{} () {} [
value: 5;
mutableHolder: @Int32Schema Mref;
@value @mutableHolder.set
mutableHolder printStack _:;
immutableHolder: [Int32Schema Cref] Mref;
@value @immutableHolder.set
immutableHolder printStack _:;
] "main" exportFunction
Int32 Ref
Int32 Cref
"Mref" use
"String" use
"control" use
Int32Schema: [0];
{} Int32 {} [
value0: 5;
value1: 9;
holder: @Int32Schema Mref;
@value0 @holder.set
("first=" holder new LF) printList
@value1 @holder.set
("second=" holder new LF) printList
0
] "main" exportFunction
first=5
second=9
addressToReference builtin (address modelValue -- reconstructedValue) Builds a typed result from a numeric address and a model value that supplies schema and mutability.storageAddress builtin (value -- address) Returns the storage address of one non-Meta value as Natx.