manuallyInitVariable

manuallyInitVariable (value --)

Inputs

Outputs

manuallyInitVariable is a designated-storage initialization builtin. It initializes a value in existing storage. Allocation and storage selection are separate operations. For an In-place local or field, NAME or .NAME and @NAME or .@NAME all designate the same storage for manual initialization.

Behavior

Example

"String" 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
  0
] "main" exportFunction

Expected Output

init
-- first -- 42
die
init
-- second -- 42
die

See also