newVarOfTheSameType

newVarOfTheSameType (schema -- newValue)

Inputs

Outputs

newVarOfTheSameType is a fresh-value creation builtin that uses only the dereferenced schema of its input.

The input may be a value or Ref, but current contents, current access path, and NIL status are ignored. Only the dereferenced schema participates. Unlike new, current Ref contents, current access path, and NIL status never participate here. Applying const or unconst to a Ref input therefore does not change this builtin’s behavior.

Behavior

Example

{} 0 {} [
  template: 7;

  "-- current contents are ignored --" printCompilerMessage
  template newVarOfTheSameType printStack _:;
  template newVarOfTheSameType known? printStack _:;

  "-- access path is ignored --" printCompilerMessage
  @template newVarOfTheSameType printStack _:;
  @template newVarOfTheSameType known? printStack _:;

  "-- known NIL Ref still uses schema --" printCompilerMessage
  0nx template addressToReference newVarOfTheSameType printStack _:;
  0nx template addressToReference newVarOfTheSameType known? printStack _:;

  "-- meta schema --" printCompilerMessage
  () newVarOfTheSameType printStack _:;
  () newVarOfTheSameType known? printStack _:;

  0
] "main" exportFunction

Expected Output During Compilation

-- current contents are ignored --
Int32
FALSE
-- access path is ignored --
Int32
FALSE
-- known NIL Ref still uses schema --
Int32
FALSE
-- meta schema --
()
TRUE

See also