new (value -- newValue)value: Value that supplies the new object.newValue: Fresh value created from value or from its referenced contents, according to the input kind.new is a fresh-value creation builtin. It creates a fresh value from a Ref, Block, or Meta current stack value.
For a Ref input, current referenced contents participate. new does not use only the dereferenced schema, so a known NIL Ref is invalid even when its dereferenced schema would otherwise be accepted. Unlike newVarOfTheSameType, current Ref contents, current access path, and NIL status all participate here. Applying const or unconst to a Ref input can therefore change whether new attempts to copy or move, and may also change validity.
For an In-place local or field, NAME or .NAME uses the immutable Ref case, while @NAME or .@NAME uses the mutable Ref case.
NIL Ref value is invalid."Owner" use
"String" use
{} () {} [
number: 7;
numberCopy: number new;
("-- immutable local -- " numberCopy " " number "\n") printList
ownerValue: 5 owner;
ownerMoved: @ownerValue new;
("-- mutable local -- " ownerMoved.valid? " " ownerValue.valid? "\n") printList
unknownValue: 0 dynamic;
"-- unknown contents through immutable Ref --" printCompilerMessage
unknownValue new printStack _:;
"-- meta value --" printCompilerMessage
() new printStack _:;
] "main" exportFunction
Module-loading wrapper lines are omitted below.
-- unknown contents through immutable Ref --
Int32
-- meta value --
()
-- immutable local -- 7 7
-- mutable local -- TRUE FALSE
newVarOfTheSameType builtin (schema -- newValue) Creates a fresh value from only the dereferenced input schema; unlike new, current contents, value knowledge, and NIL status do not participate, so a known NIL Ref can still be used there.set builtin (value destination --) Replaces an already-selected mutable same-schema destination.