fieldIsVirtual (schema ordinal -- hasNoStorage)
Inputs
schema: Object or Ref whose dereferenced schema is Struct and whose selected item is tested.ordinal: Zero-based item ordinal being tested.
Outputs
fieldIsVirtual is a selected-item storage predicate. It tests whether one selected item of the dereferenced Struct schema has no runtime field storage.
TRUE includes static items and Meta items. Current field contents do not participate. This is a schema predicate, not a read-result predicate, so a static item can make fieldIsVirtual return TRUE even though reading that item later produces a non-Meta object and virtual? returns FALSE. A static Ref-like item can make both fieldIsVirtual and fieldIsRef return TRUE, because storage kind and schema kind are tested separately.
Behavior
ordinalis a zero-based knownInt32selected-item ordinal.- If
ordinalis out of bounds for the Struct schema, the builtin raises a compilation error.
Example
{} 0 {} [
dict: {
ordinaryField: 0;
staticField: 0 virtual;
staticCodeField: {} () {} codeRef virtual;
metaField: ();
};
"-- In-place field schema versus read result --" printCompilerMessage
dict 0 fieldIsVirtual printStack _:;
@dict 0 fieldRead virtual? printStack _:;
"-- static field schema versus read result --" printCompilerMessage
dict 1 fieldIsVirtual printStack _:;
@dict 1 fieldRead virtual? printStack _:;
"-- static Ref-like field schema versus read result --" printCompilerMessage
dict 2 fieldIsVirtual printStack _:;
dict 2 fieldIsRef printStack _:;
@dict 2 fieldRead virtual? printStack _:;
"-- meta field schema versus read result --" printCompilerMessage
dict 3 fieldIsVirtual printStack _:;
@dict 3 fieldRead virtual? printStack _:;
tuple: (0 ());
"-- Tuple item storage --" printCompilerMessage
tuple 0 fieldIsVirtual printStack _:;
tuple 1 fieldIsVirtual printStack _:;
0
] "main" exportFunction
Expected Output During Compilation
-- In-place field schema versus read result --
FALSE
FALSE
-- static field schema versus read result --
TRUE
FALSE
-- static Ref-like field schema versus read result --
TRUE
TRUE
FALSE
-- meta field schema versus read result --
TRUE
TRUE
-- Tuple item storage --
FALSE
TRUE
See also
@builtin(ordinal structValue -- selectedItem)Ordinal-based one-item read with the ordinal before the Struct object.fieldReadbuiltin(structValue ordinal -- selectedItem)Ordinal-based one-item read with the Struct object before the ordinal.virtualbuiltin(--)Historical static-declaration modifier for the next local.virtual?builtin(schema -- isMeta)Historical Meta-schema test.fieldIsPrivatebuiltin(schema ordinal -- isPrivate)Visibility test for one selected Dict field.fieldIsRefbuiltin(schema ordinal -- isRefLike)Ref-like test for one selected item schema.fieldCountbuiltin(schema -- itemCount)Item count of the Struct schema.fieldIndexbuiltin(schema itemName -- ordinal)Selected item ordinal from item name under last-match rules.fieldNamebuiltin(schema ordinal -- itemName)Stored item name at one selected item ordinal.hasbuiltin(schema itemName -- hasName)Schema-level known-name presence test.schemaNamebuiltin(schema -- reportedName)Reported name of the dereferenced schema.