isConst (value -- isConst)value: Current stack value whose immutability is tested.isConst is the current stack-value immutability predicate. It tests whether the current stack value itself is immutable.
It tests only the current stack view. The result depends on the value 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. For Code values, isConst depends only on the current stack value being Code, not on whether that Code value is known, unknown, NIL, or non-NIL.
TRUE.FALSE.TRUE, regardless of whether their contents are known at compile time.TRUE, including known non-NIL, known NIL, and unknown Code values.FALSE.NAME on an In-place local produces an immutable Ref view, while @NAME produces a mutable Ref view. The two forms can therefore produce different isConst results.{} 0 {} [
value: 7;
codeLocal: {} () {} codeRef;
unknownText: 0 ("") dynamic @;
[] !codeLocal
"-- 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
-- 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
const builtin (value -- immutableView) Immutable view conversion for the current stack value.fieldIsRef builtin (schema ordinal -- isRefLike) Ref-like test for one selected item schema.isRef builtin (value -- value isRefLike) Current stack-value Ref-like test.managed? builtin (schema -- isManaged) Managed-lifetime schema test.unconst builtin (value -- mutableView) Mutable view conversion for the current stack value.