lua-users home
lua-l archive

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


Peter Hill:
> (2) Why do metamethods have a double underscore prefix? That seems to
imply
> that the metatable will be filled with other, otherwise conflicting,
> entries.

Benoit Germain:


> a metatable can be filled with whatever you want. I am currently using
this
> feature to implement a scheme similar to the proxy mechanism: a full
> userdata comes with a metatable that contains __index and __nexindex
> functions that get and set fields in the metatable itself (in addition to
> fetching predefined members as well). That way, the full userdata can be
> used as any regular table.

Wouldn't it be better to use a separate table as the proxy? That way it
could store any values (even "__blah" ones) without unexpected consequences.

*cheers*
Peter Hill.

Ki: Contractors... high-paid leeches stealing our work.
Fooker: If you think of them as disposable employees, you'll feel much
better...