manuallyInitVariable (object --)

Inputs

Outputs

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

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