lua-users home
lua-l archive

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


On 04/10/2014 09:27 AM, Dirk Laurie wrote:
2014-04-10 8:49 GMT+02:00 steve donovan <steve.j.donovan@gmail.com>:

Also, it makes particular sense when overridden by extended
metamethods, but what precisely does it mean in their absence?  That
tbl[i,j] is tbl[i][j]?  That's what I would expect from my old Fortran
days....
No, it means just what I said at the beginning. Term-by-term indexing.
Vararg maps to variable return list. In effect a fallback metamethod
if you have failed to provide one yourself.

For tbl[i,j] to mean matrix indexing requires extra information, and therefore
a metamethod — but at present such metamethod can't use that syntax.

I have a problem with that fallback. It doesn't give back the same number of results as the usual metamethod. You would have the same problems as if you were allowed to return multiple results from the normal __index metamethod.

If I get your example right then:
matrix[x, y] whould return one result while table[x, y] would return two.

--
Thomas