[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: The += operator, again
- From: David Favro <lua@...>
- Date: Wed, 05 Dec 2018 22:50:48 +0000
On December 5, 2018 11:59:47 AM UTC, Domingo Alvarez Duarte <firstname.lastname@example.org> 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 . But in my opinion ++ and -- are much less useful, and when used give fewer advantages , 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'.
: I mean in core Lua. I consider patches and forks to be vastly less useful.
: ++ 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" .