lua-users home
lua-l archive

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


HyperHacker <hyperhacker@gmail.com> writes:
> What the original post did remind me of is that I'd love to see t[nil]
> and t[] be syntactically valid, passing nil (or maybe in the second
> case, no argument) to __index or __newindex, erroring only if those
> aren't set (or they throw an error, of course). Maybe even t[1,2,3] to
> pass multiple arguments; then you could do crazy things like:

AOL ~!

__index/__newindex-only, of course...

One question would then be:  for tables, which always lookup the key in
the table and only invoke __index/__newindex if there's no existing
entry, what should it do for multiple keys?  Maybe just invoke
__index/__newindex directly without even bothering to do a lookup (and
signalling an error if there's no metatable or no __index/__newindex)?

For userdata, which doesn't (can't) do the initial lookup anyway, such a
feature seems pure win...

-miles

-- 
Sabbath, n. A weekly festival having its origin in the fact that God made the
world in six days and was arrested on the seventh.