[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: append to list operator
- From: Sean Conner <sean@...>
- Date: Thu, 15 Aug 2019 11:41:00 -0400
It was thus said that the Great Sean Conner once stated:
> It was thus said that the Great Oliver once stated:
> > Can this be rewritten using the imaginary @ operator?
> > complexLValue[#@ + 1] = newElement;
> > Now the @ would be on the left side of the assignment, this looks weird.
> Well ...
> complexLValue = @[#@ + 1] = newElement
And that wouldn't work. I'd say "What was I thinking?" but I actually
know what I was thinking when I wrote the above.
I initially started to reply by stating one could just as easily use the
__concat metamethod (assuming one had been assigned to complexLValue):
complexLValue .. newElement
but I realized that wouldn't work, it would have to be:
complexLValue = complexLValue .. newElement --
which takes us to the proposal under consideration, and I ended up with
complexLValue = @[#@ + 1] = newElement
which wouldn't work even *if* Lua had this feature.
 I have written Lua code in the past (emphasis on "the past") that
did just this, but for userdata, not a table, but the idea still