lua-users home
lua-l archive

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


On 4/11/07, Jerome Vuarand <jerome.vuarand@ubisoft.com> wrote:
Here are some very personnal reasons:

1) In Lua, contrary to C/C++, assignments are statements but not
expressions. C++ syntax relies heavily on the fact that assignations are
expressions. In Lua you have a single assignment operator, just one,
which is not in the same category at all than binary operators (+ - * /
% .. and or). So adding new assignments operators means:
 - having several assignment operators instead of just one (and going
from 1 to 2+ is much more difficult than going from n to n+1)
 - introducing ambiguity between assignment and expressions (because +=
does both)
 - introducing += will encorage people to ask for ++, both prefixed and
suffixed, and ++ will encourage people to ask for assignments to become
expressions, which will completely change the syntax and semantics of
Lua

I would love to see += and its ilk as statements, though it does seem
like a lot of new operators, and a nice syntax for the same thing
without reusing operators would be nice. I don't really connect
assignment-as-expression and ++ with +=. I quite dislike the former.

I would love to be able to do this, though:

x, y += xOffset, yOffset