[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Lua 5.3.0: operator precedence
- From: Dirk Laurie <dirk.laurie@...>
- Date: Mon, 31 Mar 2014 17:26:47 +0200
The manual says:
3.4.8 – Precedence
Operator precedence in Lua follows the table below, from lower to
higher priority:
or
and
< > <= >= ~= ==
..
+ -
* / // %
not # - (unary)
^
The new bit operators are not in here.
$ lua53
Lua 5.3.0 (work2) Copyright (C) 1994-2014 Lua.org, PUC-Rio
> 84+1<<16
5570560
> 1<<16+8
16777216
> (84+1)<<16
5570560
> 1<<(16+8)
16777216
I.e. shifts have a lower precedence than addition, as in C.
In fact, lower even than concatenation, which is not in C.
> 1 << 16 .. 8
0
But higher than the logical operators.
The C analogy suggests that the other bit operators will be
even lower down, between the comparison operators and
the junction operators.
Can we take this as the way it will be, or does the fact that it
is undocumented imply that it is open to discussion?