lua-users home
lua-l archive

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


An alternative to assignment operators (+=, etc) might be to have a
shorthand for referring to the variables on the left hand side of the
assignment. Perhaps one of the unused characters (question mark, say)
could be used for this. So if we started with:-

   longVarName = longVarName + 1

...we could change it to:-

   longVarName = ? + 1

...and then perhaps ?1, ?2, etc for multiple assignments.

&.


Lua list <lua@bazar2.conectiva.com.br> writes:
>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
>
>2) It also makes it much easier to overide the semantics without
>thinking to all corner cases introduced (C++ const-ness and copy
>constructor mechanism are in part consequences of the ambiguity
>mentionned above).
>
>3) The very fact that expressions and statements are distinct things in
>Lua makes the language much easier to teach to non-programmers, which
>constitute a non-marginal part of Lua users.
>
>I don't know which are the official reasons. The recurrence of that
>topic definitively means that we need some online list of frequently
>asked and rejected Lua heavy modifications.



#####################################################################################
This e-mail message has been scanned for Viruses and Content and cleared 
by MailMarshal.
The Blackpool Sixth Form College.
#####################################################################################