dynamic (object -- dynamicValue)
Inputs
object: Object whose compile-time contents are forgotten.
Outputs
dynamicValue: Resulting object of the same schema and general value kind, with forgotten compile-time contents where applicable.
dynamic is a current stack object forgotten-contents conversion builtin. It keeps the schema of object and keeps the same general value kind, but it may erase current value knowledge.
For a known non-NIL Ref object, the referenced target becomes forgotten while the current Ref view stays the same.
Behavior
- A known In-place object becomes the same schema with forgotten contents.
- A known non-
NILRef object stays a Ref object of the same schema, but the target contents become forgotten. - A known
NILRef object is unchanged. - An unknown Ref object is unchanged.
- A Code object keeps the same schema and still reports
FALSEunderisDynamicandunknownStable?. A knownNILCode object can lose its printedCNILmarker. A callable non-NILCode object remains callable. - Text objects keep their schema but become unknown; their known contents are forgotten.
- Meta objects are unchanged.
Example
{} 0 {} [
value: 7;
codeLocal: {} () {} codeRef;
unknownText: 0 ("") dynamic @; # an unknown Text
[] !codeLocal # a non-NIL Code
"-- In-place value --" printCompilerMessage
7 known? printStack _:;
7 dynamic printStack _:;
7 dynamic known? printStack _:;
7 dynamic isDynamic printStack _:;
"-- known Ref --" printCompilerMessage
@value known? printStack _:;
@value dynamic printStack _:;
@value dynamic known? printStack _:;
@value dynamic isDynamic printStack _:;
"-- known NIL Ref --" printCompilerMessage
0nx value addressToReference printStack _:; # a NIL Ref
0nx value addressToReference known? printStack _:;
0nx value addressToReference isDynamic printStack _:;
0nx value addressToReference dynamic printStack _:;
0nx value addressToReference dynamic known? printStack _:;
0nx value addressToReference dynamic isDynamic printStack _:;
"-- code --" printCompilerMessage
{} () {} codeRef printStack _:;
{} () {} codeRef known? printStack _:;
{} () {} codeRef isDynamic printStack _:;
{} () {} codeRef dynamic printStack _:;
{} () {} codeRef dynamic known? printStack _:;
{} () {} codeRef dynamic isDynamic printStack _:;
@codeLocal dynamic printStack _:;
@codeLocal dynamic known? printStack _:;
@codeLocal dynamic isDynamic printStack _:;
"-- text and meta --" printCompilerMessage
"hi" dynamic printStack _:;
"hi" dynamic known? printStack _:;
"hi" dynamic isDynamic printStack _:;
() dynamic printStack _:;
() dynamic known? printStack _:;
() dynamic isDynamic printStack _:;
0
] "main" exportFunction
Expected Output During Compilation
-- In-place value --
TRUE
Int32
FALSE
TRUE
-- known Ref --
TRUE
Int32 Ref
FALSE
TRUE
-- known NIL Ref --
Int32 CNIL
FALSE
FALSE
Int32 CNIL
FALSE
FALSE
-- code --
{} () {} codeRef CNIL
FALSE
FALSE
{} () {} codeRef
FALSE
FALSE
{} () {} codeRef
FALSE
FALSE
-- text and meta --
Text
FALSE
FALSE
()
TRUE
FALSE
See also
isDirtybuiltin(object -- isDirty)Current stack object instability predicate; distinct from the stable-and-unknown predicate.isDynamicbuiltin(object -- isDynamic)Current stable-and-unknown predicate; same predicate asunknownStable?.known?builtin(object -- isKnown)Preferred public name of the current stack object knownness predicate.stable?builtin(object -- isStable)Current stack object stability predicate; exact opposite ofisDirty.unknownStable?builtin(object -- isUnknownStable)Current stable-and-unknown predicate; same predicate asisDynamic.