lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> A numerical constant can be written...
> 
> As I understand it, there is no such thing as a negative numerical
> constant. However, these do exist:
> >luac -l -
> a = -3

Like -x, -3 is the minus unary operator applied over the constant 3.
(If -3 was a lexical constant, Lua would read "x-3" as "x" followed by
"-3".)

Lua does constant folding, so -(3) is coded internally as -3, but this
is an optimization. (Check the code for "a = 3 + 5".)

-- Roberto