Re: how to iterate "in lua defined attributes" of an object

Daniel Wallin <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
On Sun, Apr 25, 2010 at 05:50:14PM +0200, Gregor Burger wrote:
> hi,
> 
> i'm searching for this for a long time. i basically need the equivalent of
> the python '__dict__' object for an object. i know there exists a class_info
> class which has an 'attribute' table but this table doesn't seem to include
> the attributes that were defined in the lua code.

There isn't currently any documented or supported way of doing this. I
have plans to include something like this for 1.0, but it hasn't been
done yet. If you want to produce a patch you can look at the code in
object_rep.cpp, more specifically the get_instance_value() function.

Basically the lookup for an instance member goes:

 1. Look in the environment for the object.
 2. If it isn't there, and the environment table has a metatable; look in
    that metatable.

HTH,
-- 
Daniel Wallin
BoostPro Computing
http://www.boostpro.com

------------------------------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.