[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Best way to have table-like fields on userdata
- From: Tomas <tomas@...>
- Date: Tue, 28 Nov 2006 16:44:23 -0200 (BRST)
What is the best way to support something akin to table like fields on
userdata, so you can have:
foo.status = 201
where foo is a userdata?
Using the metatable for adding methods as described in PiL works well for
adding methods to it, but providing an __index on the metatable causes
__index to be invoked rather than looking up the value in the metatable.
Try __newindex. See PiL's page 267.