Blocks

3.3.1 – Blocks A block is a list of statements, which are executed sequentially: block ::= {stat} Lua has empty statements that allow you to separate statements with semicolons, start a block with a semicolon or write two semicolons in sequence: stat ::= ‘;’ Function calls and assignments can start with an open parenthesis. This possibility leads to an ambiguity in Lua's grammar. Consider the following fragment: a = b + c (print or io.write)('done') The grammar could see it in two ways:

Bitwise Operators

3.4.2 – Bitwise Operators Lua supports the following bitwise operators: &: bitwise AND |: bitwise OR ~: bitwise exclusive OR >>: right shift <<: left shift ~: unary bitwise NOT All bitwise operations convert its operands to integers (see §3.4.3), operate on all bits of those integers, and result in an integer. Both right and left shifts fill the vacant bits with zeros. Negative displacements shift to the other direction; displacements with absolute values equal to o

Assignment

3.3.3 – Assignment Lua allows multiple assignments. Therefore, the syntax for assignment defines a list of variables on the left side and a list of expressions on the right side. The elements in both lists are separated by commas: stat ::= varlist ‘=’ explist varlist ::= var {‘,’ var} explist ::= exp {‘,’ exp} Expressions are discussed in §3.4. Before the assignment, the list of values is adjusted to the length of the list of variables. If there are more values than needed, the excess valu

assert()

assert (v [, message]) Calls error if the value of its argument v is false (i.e., nil or false); otherwise, returns all its arguments. In case of error, message is the error object; when absent, it defaults to "assertion failed!"

Arithmetic Operators

3.4.1 – Arithmetic Operators Lua supports the following arithmetic operators: +: addition -: subtraction *: multiplication /: float division //: floor division %: modulo ^: exponentiation -: unary minus With the exception of exponentiation and float division, the arithmetic operators work as follows: If both operands are integers, the operation is performed over integers and the result is an integer. Otherwise, if both operands are numbers or strings that can be converted to number