lua-users home
lua-l archive

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

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 --[1]

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.

  -spc (Sigh)

[1]	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