Re: Best way to have table-like fields on userdata
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Best way to have table-like fields on userdata
- From: Tomas <tomas@...>
- Date: 2006年11月28日 16:44:23 -0200 (BRST)
Hi Brian
What is the best way to support something akin to table like fields on
userdata, so you can have:
foo.status = 201
foo:puts("hello world")
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.
Regards
Tomas