callField

callField (dict name -- fieldResult)

Inputs

Outputs

callField selects one Dict field by known Text name input and then applies the same field-handling semantics as .NAME.

Selection happens inside the builtin from the two data inputs.

Behavior

When the selected field is called, direct scope lookup inside that call matches .NAME: outer Dict fields are available, self is also available when dict was reached through a Ref, callable field Dict fields are available during PRE and CALL, closure is available for non-Meta non-static callable field Dict values, and direct-name conflicts during CALL favor the callable field Dict.

Example

{} 0 {} [
  dict: {
    outerValue: 7;
    number: 7;
    textField: "hi";
    metaField: ();
    blockField: [
      "-- block field --" printCompilerMessage
      self.outerValue printStack _:;
    ];
    choice: ["-- fallback --" printCompilerMessage];
    choice: {
      CALL: ["-- matched --" printCompilerMessage];
      PRE: ["-- PRE --" printCompilerMessage FALSE];
    };
  };
  numberName: "number";
  choiceName: "choice";

  "-- In-place field: callField versus .@NAME --" printCompilerMessage
  @dict numberName callField printStack _:;
  @dict .@number printStack _:;

  "-- text field --" printCompilerMessage
  @dict "textField" callField printStack _:;

  "-- meta field --" printCompilerMessage
  @dict "metaField" callField printStack _:;

  @dict "blockField" callField
  @dict choiceName callField

  0
] "main" exportFunction

Expected Output During Compilation

-- In-place field: callField versus .@NAME --
7 Cref
7 Ref
-- text field --
"hi"
-- meta field --
()
-- block field --
7 Cref
-- PRE --
-- fallback --

See also