lua-users home
lua-l archive

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

On December 5, 2018 11:59:47 AM UTC, Domingo Alvarez Duarte <> wrote:
>I've updated the repositories with fixes for compound operators on 
>upvalues and also added pre/pos increment operators "++/--".

How do you differentiate "--" as an operator from a comment-start?

I have been an advocate for the += operator, which I think is sorely lacking in Lua, for many years [1].  But in my opinion ++ and -- are much less useful, and when used give fewer advantages [2], and pose more issues, such as already being used for comments.  Yet for some reason people can't help lumping them all together and then using the issues with the unary operators as a purported complication of the binary operator, as well as increasing the overall size of the addition to the language, leading to objections of 'bloat'.

-- David

[1]: I mean in core Lua.  I consider patches and forks to be vastly less useful.

[2]: ++ and -- are very frequently used in languages such as C for loop iteration.  In Lua, iteration takes place much more often via ipairs(), and even the numeric for loop does not require explicit increment. Furthermore, the ++ operator in C often compiles to a distinct hardware instruction; while in the Lua VM, it would presumably generate code no different than "x+=1" .