or (leftOperand rightOperand -- combinedValue)
Inputs
leftOperand: Left operand of the logical or bitwise operation.rightOperand: Right operand of the logical or bitwise operation.
Outputs
combinedValue: OR result in the operand schema.
or accepts same-schema Cond, Nat, and Int objects. Both inputs are dereferenced and must be non-NIL. The result keeps that schema.
This is not short-circuit control flow. By the time or runs, both operands are already on the data stack.
Behavior
- For Cond, the operation is logical disjunction. The identity value is
FALSEand the dominating value isTRUE. - For Nat and Int, the operation is bitwise OR. The dominating value is the all-bits-set value of that schema and the identity value is zero.
- For Int schemas, the bitwise result is computed on the schema's fixed-width bit pattern and then interpreted again as the same Int schema.
- If one operand is known to be the dominating value, the result is known immediately.
- If one operand is known to be the identity value, the result follows the other operand.
- If both operands are known at compile time, the result is computed at compile time. Otherwise, the builtin produces an unknown result of the same schema.
Example
{} () {} [
"-- no short-circuit cond --" printCompilerMessage
"-- left operand --" printCompilerMessage TRUE
"-- right operand --" printCompilerMessage FALSE
or printStack _:;
"-- cond --" printCompilerMessage
FALSE TRUE or printStack _:;
FALSE FALSE or printStack _:;
unknownCond: FALSE dynamic;
TRUE unknownCond or printStack _:;
FALSE unknownCond or printStack _:;
"-- nat32 masks --" printCompilerMessage
0xF0n32 0x0Cn32 or printStack _:;
0xFFFFFFFFn32 0x0Cn32 or printStack _:;
0n32 0x0Cn32 or printStack _:;
unknownNat: 0n32 dynamic;
0xFFFFFFFFn32 unknownNat or printStack _:;
0n32 unknownNat or printStack _:;
"-- int32 bitwise --" printCompilerMessage
-1 6 or printStack _:;
6 3 or printStack _:;
] "main" exportFunction
Expected Output During Compilation
-- no short-circuit cond --
-- left operand --
-- right operand --
TRUE
-- cond --
TRUE
FALSE
TRUE
Cond
-- nat32 masks --
252n32
4294967295n32
12n32
4294967295n32
Nat32
-- int32 bitwise --
-1
7
See also
andbuiltin(leftOperand rightOperand -- combinedValue)Combines two Cond or Whole objects with bitwise or logical AND semantics.lshiftbuiltin(object shiftCount -- shiftedValue)Performs a bitwise left shift on a Whole object and keeps the same schema.rshiftbuiltin(object shiftCount -- shiftedValue)Performs a bitwise right shift on a Whole object and keeps the same schema.xorbuiltin(leftOperand rightOperand -- combinedValue)Combines two Cond or Whole objects with logical exclusive-OR or bitwise XOR semantics.~builtin(object -- invertedValue)Performs logical NOT for Cond or bitwise complement for a Whole object.