lua-users home
lua-l archive

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

	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.