[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: The += operator, again
- From: Frank Kastenholz <fkastenholz@...>
- Date: Wed, 5 Dec 2018 20:44:40 -0500
One place where I think that “++” or equivalent might be as syntactic sugar for adding something to the end of a list
Fubar[++]=...
As shorthand for
Fubar[#Fubar+1]=...
But it’s not that big a deal
Frank
> On Dec 5, 2018, at 5:50 PM, David Favro <lua@meta-dynamic.com> wrote:
>
>
> 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" .
>