[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: why not ++ in lua?
- From: Andreas Stenius <kaos@...>
- Date: Wed, 30 Nov 2005 08:32:59 +0100
Rici Lake wrote:
[...]
An intermediate proposal with simpler semantics (although its arguably a
lot uglier) is to allow pseudovariables of the form $<integer> to appear
in assignment statements; $<i> refers to the rvalue corresponding to the
i'th lvalue, and, for convenience, the <integer> defaults to the current
position in the expression list. This would allow things like:
a[i] =$+ 1 -- increment a[i], or whatever a's metamethods make of it.
a[i], a[j] = $2, $1 -- swap a[i] and a[j]
[...] so it might
satisfy the need. The second example could be handy if i and j were
actually expressions.
I like this. What I would like to see is to not have to type the var name
twice in the assignment (especially those with quite long names, maybe even
in tables, with a long key var too..), which this solves quite neatly, IMO.
Feels like it shouldn't be too hard to achieve either :)
//Andreas