known? (object -- isKnown)

Inputs

Outputs

known? is the preferred public name of the current stack-object knownness predicate. It tests whether the current stack object is fully known at compile time.

This predicate follows the referenced target for known non-NIL Ref objects. For In-place storage, stability alone is insufficient for TRUE: a stable object may be unknown and reports FALSE, and an unstable or forgotten In-place object reports FALSE; other schemas use their own knownness rules. Current stack Code objects produced by user-visible creation paths such as codeRef, exportFunction, and block assignment to Code still report FALSE. This includes callable non-NIL Code objects reached through those paths and known NIL Code objects.

Behavior

Example

{} 0 {} [
  knownValue: 7;
  unknownValue: 0 dynamic;
  unknownText: 0 ("") dynamic @; # an unknown Text
  codeLocal: {} () {} codeRef;
  [] !codeLocal # a non-NIL Code

  "-- In-place values --" printCompilerMessage
  7 known? printStack _:;
  7 isDynamic printStack _:;
  7 stable? printStack _:;
  unknownValue known? printStack _:;
  unknownValue isDynamic printStack _:;
  unknownValue stable? printStack _:;

  "-- references ask about the target too --" printCompilerMessage
  @knownValue known? printStack _:;
  @unknownValue known? printStack _:;
  0nx knownValue addressToReference known? printStack _:; # a NIL Ref

  "-- text, meta, code --" printCompilerMessage
  "hi" known? printStack _:;
  0nx "" addressToReference known? printStack _:;
  unknownText known? printStack _:;
  () known? printStack _:;
  {} () {} codeRef known? printStack _:;
  {} () {} codeRef dynamic known? printStack _:;
  @codeLocal known? printStack _:;

  0
] "main" exportFunction

Expected Output During Compilation

-- In-place values --
TRUE
FALSE
TRUE
FALSE
TRUE
TRUE
-- references ask about the target too --
TRUE
FALSE
FALSE
-- text, meta, code --
TRUE
FALSE
FALSE
TRUE
FALSE
FALSE
FALSE

See also