[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Standard Object Reflection (was Re: OOP in daydream...)
- From: "Steve Donovan" <sjdonova@...>
- Date: Wed, 19 Jan 2005 12:04:45 +0200
Although there's more than one way to skin the OOP
cat in Lua, it would be useful to have some conventions.
For example, consider a class browser. Such code can't
even assume that the methods are stashed in the
object's metatable! One solution is to expect class
systems to export some standard functions:
A user-defined iterator for finding all the classes defined
in the system. (If it isn't defined, we can probably cope
by browsing the global environment recursively)
Any table intended to be used as a class will export
a method _base, which may of course return nil.
Any class must define this iterator, which gives the
available methods; from there, the debug interface
could give us where they're physically defined.
(Whether this gives _all_ inherited methods, or just methods
defined by this class, is an interesting question.
I'd say this should be an option)
So no matter how one sets up one's object system,
such a convention would allow general tools
to be built that don't require detailed knowledge
of the object system.