[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: help to (slightly) modify Lua interpreter
- From: David Manura <dm.lua@...>
- Date: Thu, 5 Nov 2009 20:57:33 -0500
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
interned.
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} }
[1] http://numlua.luaforge.net/
[2] http://bluedino.net/luapix/carvalho-numlua.pdf
[3] Chapter 16 of Lua Programming Gems - http://www.lua.org/gems/
[4] http://lua-users.org/wiki/LuaMatrix