storageAddress (object -- address)
Inputs
object: Object whose storage address is queried.
Outputs
storageAddress is a current stack object storage query. It returns the storage address of one non-Meta object as known or unknown Natx. The result depends on the current stack object, including known nilness.
Behavior
- In-place objects, non-
NILRefobjects, non-NILCodeobjects, and non-NILTextobjects produce an unknownNatxresult. - For non-
NILText, the reported address is the address of the referenced UTF-8 storage. - Known
NILRef, Text, and Code objects produce the known zero address0nx. - Taking the address of a known non-
NILRef destabilizes its referenced target, including through an immutable view. - Meta objects are invalid.
Example
{} () {} [
value: 7;
text: "hello";
code: {} () {} codeRef;
"-- immutable and mutable Ref views --" printCompilerMessage
value storageAddress printStack _:;
@value storageAddress printStack _:;
"-- text and known NIL cases --" printCompilerMessage
text storageAddress printStack _:;
0nx value addressToReference storageAddress printStack _:; # a NIL Ref
@code storageAddress printStack _:;
] "main" exportFunction
Expected Output During Compilation
-- immutable and mutable Ref views --
Natx
Natx
-- text and known NIL cases --
Natx
0nx
0nx
See also
addressToReferencebuiltin(address modelValue -- reconstructedValue)Typed reconstruction from a numeric storage address. Ref-like model objects keep their schema, and direct non-Ref-like model objects produceRefresults.alignmentbuiltin(schema -- alignment)KnownNatxalignment requirement of the dereferenced schema.manuallyDestroyVariablebuiltin(object --)Manually destroys the designated object in place without freeing the storage.manuallyInitVariablebuiltin(object --)Manually initializes the designated object in existing storage without allocating the storage.storageSizebuiltin(schema -- size)KnownNatxstorage size of the dereferenced schema.