lua-users home
lua-l archive

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


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