lua-users home
lua-l archive

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


There are many ways to implement multi-indexed tables in Lua, but
since that is not the main point of the post, I'll just pick one,
namely to wrap the indices into a tuple as described for example in
these articles on the Lua wiki:

http://lua-users.org/wiki/SimpleTuples
http://lua-users.org/wiki/FunctionalTuple

In either case, you code something like tbl[tuple(1,2)] where you
would have liked to code tbl[1,2]. And you can obviously monkey-patch
rawget and rawset to accept more arguments.

Now the real questions:

1. Is there any syntactic reason why one can't patch Lua so that
t[1,2] won't raise a compilation error, but instead invoke
__index(t,1,2) or __newindex(t,1,2,v)?
2. Has anyone done it already?