lua-users home
lua-l archive

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


On Thu, Nov 5, 2009 at 8:50 PM, Fabien <fleutot+lua@gmail.com> wrote:
> Beware that translating multiple assignments might be trickier than it
> seems, if right-hand-side terms and/or __newindex methods have side effects:
> foo, bar[i,j], bar[k,l] = f1(), f2()

This is in fact the case that makes this so non-trivial.  It is not
difficult to do a token-filter that copes with the difference between
A[i,j] and A[i,j] = value, but multiple assignment needs a proper AST
transformation.

A valid concern in this case is that A[i,j] has to be as fast as
possible. David's A[i][j] is perhaps the most natural way to wrap a
Lua multidimensional table (as in C) but not if you are hooking into
an API that provides a get(), probably using index calculation. (Then
A[i] has to be some intermediate object; the old problem of
temporaries)