lua-users home
lua-l archive

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

On Thu, Nov 5, 2009 at 11:16 AM, Roberto Ierusalimschy wrote:
> Do you plan to make m[i, j] the same as m[i][j]?

Numeric Lua [1-3] uses the m[i][j] approach.  This allows a reasonable
syntax, without patching, for indexing and assignment:

  m[i][j] = m[j][i]

Furthermore, m[i] may represent a vector and you can perform vector
operations on it.  The implementation is described in [3].
Internally, the matrix is a 1D array with __index/__newindex
metamethods, and intermediate objects such as m[i] are lazily

LuaMatrix [4] also supports this syntax as a side-effect of matrices
being implemented in a simple way as nested Lua tables:

  { {1, 2},
    {3, 4} }

[3] Chapter 16 of Lua Programming Gems -