set

set (value destination --)

Inputs

Outputs

set replaces an already-selected mutable same-schema destination after dereferencing both inputs. No selection happens inside the builtin.

set is the final replacement step after a separate selection form such as @NAME, .@NAME, @, or fieldRead. After dereferencing, source mutability decides whether the source is copied or moved. A Ref source differs from a direct value only by that source mutability.

set replaces the selected destination object itself. If destination is a Ref, the object reached through that Ref is replaced; the stored Ref value is not changed. Replacing a stored Ref value instead requires a combined selection-and-write form such as ! or fieldWrite.

Behavior

Example

"Owner" use
"String" use

{} () {} [
  copySource: 7;
  copyTarget: 0;
  copySource @copyTarget set
  ("-- immutable value path copies -- " copySource " " copyTarget "\n") printList

  moveSource: 5 owner;
  moveTarget: 0 owner;
  @moveSource @moveTarget set
  ("-- mutable value path moves -- " moveSource.valid? " " moveTarget.valid? "\n") printList
] "main" exportFunction

Expected Output

-- immutable value path copies -- 7 7
-- mutable value path moves -- FALSE TRUE

See also