unconst (object -- mutableView)
Inputs
object: Current stack object whose view may become mutable.
Outputs
mutableView: Resulting stack object in mutable view where valid.
unconst is a current stack-object mutable-view conversion builtin. It converts the current stack object to a mutable view where valid.
For Ref inputs, only the current stack object changes. The referenced storage and any other references remain unchanged.
Behavior
- An immutable Ref input becomes the corresponding mutable Ref to the same target.
- A mutable Ref input is returned unchanged.
NAMEon a non-static, non-callable In-place local is valid because that form produces an immutableRefview; see selection.unconstreturns the mutable view to the same target.- Code and Text inputs are returned unchanged, including callable non-
NILCode inputs. - Meta inputs are returned unchanged and still report
FALSEunderisConst. - In-place inputs are invalid.
Example
{} 0 {} [
value: 7;
codeLocal: {} () {} codeRef;
unknownText: 0 ("") dynamic @; # an unknown Text
[] !codeLocal # a non-NIL Code
"-- current Ref view only --" printCompilerMessage
value printStack _:;
value unconst printStack _:;
value printStack _:;
@value printStack _:;
@value unconst printStack _:;
value isConst printStack _:;
value unconst isConst printStack _:;
@value unconst isConst printStack _:;
"-- accepted non-Ref inputs are unchanged --" printCompilerMessage
"hi" unconst printStack _:;
unknownText unconst isConst printStack _:;
{} () {} codeRef unconst isConst printStack _:;
@codeLocal unconst isConst printStack _:;
() unconst isConst printStack _:;
0
] "main" exportFunction
Expected Output During Compilation
-- current Ref view only --
7 Cref
7 Ref
7 Cref
7 Ref
7 Ref
TRUE
FALSE
FALSE
-- accepted non-Ref inputs are unchanged --
"hi"
TRUE
TRUE
TRUE
FALSE
See also
constbuiltin(object -- immutableView)Immutable view conversion for the current stack object.fieldIsRefbuiltin(schema ordinal -- isRefLike)Ref-like test for one selected item schema.isConstbuiltin(object -- isConst)Current stack-object immutability test.isRefbuiltin(object -- object isRefLike)Current stack-object Ref-like predicate.managed?builtin(schema -- isManaged)Managed-lifetime schema test.