lua-users home
lua-l archive

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


Hi,

Peter Hill:
> An example (in the basic line of the one given by Wim Couwenberg, but
> without the extra 'state' stuff which I'm not sure why it's there) is:

The extra state is needed to keep track of hidden keys.  A key that is
defined in an "inheritance" chain hides all the same keys further up that
chain.  Enumeration should respect this data hiding.  Both your example and
that of R. Lake don't.  What's more, both these examples simply don't work!
Shame on you guys!  ;-)

> If someone has a sample __index function I'll try to come up
> with an example matching __next.

It's common that such a function accepts indices from some finite list, but
this list is not reperesented as the keys in a table, or even in Lua.
Userdata do this a lot (store keys in an internal C array.)  Another example
would be a generic object binding where the keys are not fixed but must be
internally queried by some other specific method (COM for example, eeeek!)

Bye,
Wim