On Fri, Mar 6, 2020 at 6:16 PM Diego Nehab wrote:
In other words, t[f()] is always a single-index access, even when f() returns multiple values.
IMO, that would make the whole proposal almost useless.
Do you think that accessing a multi-index table should only be done indirectly through a function that returns the multiple required indices? Or do you believe that this is would be the typical usage?
I don’t.
The metamethods can do whatever they want with the '...'. The behavior is the same when there already exists an entry in the table with a single index, but there should never "already exist" a multi-index entry in a table.
Does it mean that
- t[i,j] will always invoke a metamethod,
- it's the programmer's task to save/load multi-index values somewhere by implementing some logic in __index/__newindex?
If that's true, then the whole proposal is absolutely useless.
It does solve exactly the problem it sets out to solve. It is the programmer’s job to define the metamethods for all userdata representing the types they need when writing the Lua bind of a library. How is this any different? There is no free lunch.