isConst (object -- isConst)

Inputs

Outputs

It tests only the current stack view. The result depends on the object on the stack, not on whether the same underlying storage is also reachable through another Ref with different mutability. The view-changing builtins const and unconst can therefore change this result only for Ref inputs.

Behavior

Example

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

  "-- mutable versus immutable Ref views --" printCompilerMessage
  @value isConst printStack _:;
  value isConst printStack _:;
  @value const isConst printStack _:;
  value unconst isConst printStack _:;

  "-- In-place values --" printCompilerMessage
  7 isConst printStack _:;
  0 dynamic isConst printStack _:;

  "-- Text and Code are const stack values --" printCompilerMessage
  "hi" isConst printStack _:;
  unknownText isConst printStack _:;
  {} () {} codeRef isConst printStack _:;
  {} () {} codeRef dynamic isConst printStack _:;
  @codeLocal isConst printStack _:;

  "-- Block and meta are not const stack values --" printCompilerMessage
  [] isConst printStack _:;
  () isConst printStack _:;

  0
] "main" exportFunction

Expected Output During Compilation

-- mutable versus immutable Ref views --
FALSE
TRUE
TRUE
FALSE
-- In-place values --
FALSE
FALSE
-- Text and Code are const stack values --
TRUE
TRUE
TRUE
TRUE
TRUE
-- Block and meta are not const stack values --
FALSE
FALSE

See also