+ (left right -- sum)
Inputs
left: Left input object.right: Right input object.
Outputs
sum: Sum object.
This builtin accepts whole and real numbers. Both inputs are dereferenced and must be non-NIL. The operands must have the same schema.
Behavior
- Whole-number schemas use integer addition semantics.
- Real schemas use floating-point addition semantics.
- If both operands are known at compile time, the result is computed at compile time.
- If either operand is known
0, the result preserves the other operand's schema. If that other operand is unknown, the result remains unknown. - Otherwise, the builtin produces an unknown result of the same schema.
Example
{} () {} [
unknownInt: 7 dynamic;
"-- int32 --" printCompilerMessage
3 4 + printStack _:;
0 7 + printStack _:;
7 0 + printStack _:;
"-- zero with unknown int32 --" printCompilerMessage
0 unknownInt + printStack _:;
"-- real32 --" printCompilerMessage
2.5r32 4.0r32 + printStack _:;
] "main" exportFunction
Expected Output During Compilation
-- int32 --
7
7
7
-- zero with unknown int32 --
Int32
-- real32 --
6.5r32
See also
*builtin(multiplicand multiplier -- product)Multiplies two numeric objects.-builtin(minuend subtrahend -- difference)Subtracts the second numeric object from the first./builtin(dividend divisor -- quotient)Divides numeric objects within the same schema; Whole division stays whole, while Real schemas use floating division.modbuiltin(dividend divisor -- remainder)Computes the remainder of numeric division; signed Int, unsigned Nat, and Real objects each follow their own remainder semantics.negbuiltin(object -- negatedValue)Negates a signed Int or Real object and keeps the same schema.