callField (inputs... dict name -- outputs...)
Inputs
inputs...: When the selected field is callable, zero or more objects consumed by it; for a non-callable field no additional input is consumed.dict: Dict object or Ref to Dict used for field selection.name: Known Text field name used for selection.
Outputs
outputs...: When the selected field is callable, zero or more objects it leaves; for a non-callable field, the selected field value is read.
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
- A known
NILText name is invalid. - Matching candidates are tried from newest to oldest.
- A Block field is called.
- A Code field is called. Known
NILCode is invalid. - A callable Dict field is selected with the same
PREandCALLrules as.NAME, then itsCALLfield is called. - A non-static In-place field, including a non-callable Dict field, produces a new immutable Ref to the selected item, even when
dictwas reached mutably. - A Ref field produces a copied Ref object.
- A Text field produces a copied Text object.
- A static or Meta field produces a new object from compile-time information instead of runtime field storage.
- The empty name
""selects unnamed fields and still follows the same newest-to-oldest candidate order. - The empty Tuple
()is invalid because the first input must dereference to Dict. - If no candidate matches, or if every matching callable Dict field fails its
PREtest, the builtin raises a compilation error.
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 objects, 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
.@NAMEnode.@NAMENamed field read without calling..NAMEnode.NAMENamed field mention and call if callable.@builtin(ordinal structValue -- selectedItem)Ordinal-based data-input selection and read with the ordinal before the Struct object. Callable items are read, not called.fieldReadbuiltin(structValue ordinal -- selectedItem)Ordinal-based data-input selection and read with the Struct object before the ordinal. Callable items are read, not called.