!

! (value ordinal structTarget --)

Inputs

Outputs

Writes one selected item by zero-based item ordinal, with the value and ordinal before the Struct target.

Both value and structTarget are dereferenced first. For In-place selected items, a Ref value therefore contributes the value it references. For Ref selected items, replacement still follows the selected item's own Ref schema.

Behavior

fieldIsRef describes the selected item schema, not the accepted source form after dereferencing. A non-static In-place item can therefore still require a direct same-schema value even though reading the same item yields a Ref result, while a Ref item can accept either a matching Ref or a direct value of its referent schema.

Example

{} 0 {} [
  value: 1;
  dict: {
    ordinaryField: 2;
    referenceField: @value;
    codeField: {} () {} codeRef;
  };

  "-- In-place item write rule --" printCompilerMessage
  dict 0 fieldIsRef printStack _:;
  7 0 @dict !
  0 @dict @ new printStack _:;

  "-- Ref item write rule --" printCompilerMessage
  dict 1 fieldIsRef printStack _:;
  5 1 @dict !
  1 @dict @ printStack _:;

  "-- code item write rule --" printCompilerMessage
  dict 2 fieldIsRef printStack _:;
  ["-- code item compiled --" printCompilerMessage] 2 @dict !
  2 @dict @ printStack _:;

  list: (1 2) dynamic;
  ordinal: 0 dynamic;
  "-- uniform struct through unknown ordinal --" printCompilerMessage
  9 ordinal @list !
  @list new printStack _:;

  0
] "main" exportFunction

Expected Output During Compilation

-- In-place item write rule --
FALSE
7
-- Ref item write rule --
TRUE
5 Ref
-- code item write rule --
TRUE
-- code item compiled --
{} () {} codeRef
-- uniform struct through unknown ordinal --
Int32 2 array

See also