"or" is a reserved word in the programming language Lua.

In the BNF syntax of Lua, it appears as a terminal atom in one substitution rule:
binopor
"binop" appears as a nonterminal atom in one substitution rule:
expexp binop exp

"or" is the disjunctive binary logical operator. Like the control structures, all logical operators consider "nil" as false and anything else as true. The disjunction operator "or" returns its first argument if it is different from "nil"; otherwise, it returns its second argument. (Both "and" and "or" use short-cut evaluation, that is, the second operand is evaluated only if necessary.)

There are two useful Lua idioms that use the logical operator "or". The first idiom is
x = x or v
which is equivalent to
if x == nil then x = v end
This idiom sets x to a default value v when x is not set.

The second idiom is
x = a and b or c
which should be read as x = (a and b) or c. This idiom is equivalent to
if a then x = b else x = c end
provided that b is not "nil".


Other systems do not use short-cut evaluation (a limited form of lazy evaluation), and both operands are always evaluated fully before the result of the "or" operation is determined. Yet other systems, nondeterministic systems, usually found in parallel processing environments, guarantee that the result of the "or" operation is logically correct, but does not guarantee that both operands are fully evaluated, it does not guarantee that either one in particular is evaluated (Lua guarantees that the first operand is evaluated), and it does not guarantee that an operand will not be only partially evaluated (Lua guarantees that the second operand will either be evaluated or not, with no in-between). Using impure functions or expressions with side-effects in nondeterministic systems is therefore considered harmful.

And, in other programming languages, the "or" keyword can have another meaning: a bitwise "or" on two numeric (usually unsigned integer) operands (giving another number, of the same type, as a result). A number may be considered an array of bits; in Eindhoven notation, any number (b) may be expressed as (+ : iZ : bi * 2i) - standard binary notation - each bi being either 0 or 1, thus making an array of bits. (For signed values, the sign bit is considered just another bit in the array; for integers, negative values of i need not be considered.) The "numeric or" performs the "logical or" operation on bits in corresponding positions in the two operands, and places the result of each "logical or" in the corresponding position in the result. In symbols, "b or c" evaluates to (+ : iZ : (bi or ci) * 2i).

The C symbol for "logical or" is || and the C symbol for "numeric or" is |.