manuallyInitVariable (object --)
Inputs
object: Object or Ref object whose designated object is initialized.
Outputs
- None.
manuallyInitVariable is a designated-storage initialization builtin. It initializes an object in existing storage. Allocation and storage selection are separate operations. For a non-static, non-callable In-place local or field (see selection), NAME or .NAME and @NAME or .@NAME all designate the same storage for manual initialization.
Behavior
- If
objectis a mutable or immutableRef, the builtin initializes the object in the referenced storage. - Otherwise, it initializes the designated local, field, or temporary object itself.
- The builtin does not allocate the underlying storage address.
Example
"String" use
"memory.mplFree" use
"memory.mplMalloc" use
Tracer: {
value: 0;
INIT: [
("init\n") printList
42 !value
];
DIE: [
("die\n") printList
];
};
{} 0 {} [
slot: Tracer storageSize mplMalloc @Tracer addressToReference;
@slot manuallyInitVariable
("-- first -- " slot.value "\n") printList
slot manuallyDestroyVariable
@slot manuallyInitVariable
("-- second -- " slot.value "\n") printList
slot manuallyDestroyVariable
Tracer storageSize slot storageAddress mplFree
0
] "main" exportFunction
mplFree releases the allocated storage after manuallyDestroyVariable destroys the object; destruction and storage release are separate.
Expected Output
init
-- first -- 42
die
init
-- second -- 42
die
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.storageAddressbuiltin(object -- address)Current stack-object storage query; knownNILRef,Text, andCodeobjects produce0nx.storageSizebuiltin(schema -- size)KnownNatxstorage size of the dereferenced schema.