Hi Jean-Louis,
it seems that Rick is currently not online, so I try to give some shots,
hoping they may help a little bit.
[One problem in OO is the terminology, which sometimes comes into ones
way (instead of clarifying concepts, sometimes they obfuscate them,
unfortunately). There are quite a few synonyms, like "object" ==
"instance" == "value" etc. or "class" == "type" etc.]
On 08.08.2011 10:23, Jean-Louis Faucher wrote:
> I try to understand the underlying model for object, class, metaclass
> (source excerpt at the end of the mail). Not easy...
ooRexx has been quite influenced by Smalltalk, so some of the concepts
are directly from there.
In general there are no class methods!
(This means among other things that all methods are instance methods!)
:)
---
* There is simply a "class" that allows one to define methods and
attributes the methods of a class can have direct access to.
o A '"method" is a function/procedure that is only available
for instances of the class in which the methods are defined.
* An "object" is just an instance of a class. The object possesses
the functionality/"behaviour" of the methods of its class.
* There is a "class hierarchy" which is used when method resolution
takes place with the concept that all methods (not attributes!) of
all the superclasses (shortest path to root class) get inherited.
(This is also the area where scope becomes important w.r.t. method
resolution, but also access to attributes, i.e. concurrency issues
and the like.)
o The class hierarchy allows an object to have more methods
(functionality/behaviour) than defined in its own class, by
means of inheritance.
* The root of a class hierarchy is usually calld "Object", which is
a class, as it defines methods. As all other classes in ooRexx are
derived directly (by default) or indirectly from this root class,
its methods (functionality/behaviour) is inherited by all other
classes (and its instances)!
---
In dynamic languages the class definitions (the name, the methods) are
represented in objects as well. The class used for creating objects that
keep the definition of a class in ooRexx (and many other languages) is
called "Class". As instances of this class describe the structure and
behaviour of individual classes the term "metaclass" is used for it. So
the ooRexx class "Class" is the metaclass of ooRexx. Of course, if one
subclasses "Class" it inherits all abilities of "Class" and as such
keeps on being able to maintain the definition of classes. An instance
of "Class" or one of its subclasses (hence of any metaclass) is called
"class object".
The instance methods of metaclasses (i.e. "class objects") are called
"class methods", indicating that these methods belong to the class object.
---
When ooRexx starts up the class hierarchy is created in native code and
from the image. I.e. all ooRexx supplied classes build (and are
represented in) the ooRexx class hierarchy in the form of class objects.
Each of these class objects maintains e.g. the name of the class and the
methods, instances of this class should get assigned to at creation time
(which is done in the 'new' method of "Class").
At runtime one can access these class objects with their environment
symbol, which is the name of the class preceeded by a dot, e.g.:
".object", ".class", ".array" and the like.
---
One speciality (and very powerful feature) of ooRexx is its ability to
add/remove methods from instances ("one-off-objects")! Cf. e.g. the
"Object"'s methods "setMethod" and "unsetMethod", but also the "Class"
method "enhanced" to create instances of a class which get additional
methods (hence "one-off").
It is also possible to change the set of methods instances of a class
get assigned to, when they get created. Cf. the "Class" methods
"method", "methods", "define" and "delete", which allow to maintain the
methods instances of a class should get assigned to at the time they got
created.
Note: the method "instanceMethod" and "instanceMethods" in the root
class "Object" allow one to fetch the actual instance method(s) of an
object (ie. also from one-off objects).
---
Finally ad methods of a class object: all methods of a class object are
"instance methods", sometimes dubbed "class methods", because they are
the instance methods of a metclass/class object. A class object is just
a normal ooRexx object and as such it is possible to add/remove instance
methods to/from it!
When an ooRexx class defines methods with the subkeyword "class" then
these methods will be added to the class object (as instance methods of
the class object).
---
Hope that helps clarify a few of your questions.
Ad ooRexx native code and implementation, this is something that
probably Rick is the only one who can answer at the moment.
---rony
>
> I can't find a suitable definition for the ??? below.
>
> Extracted from rexxref :
>
> 5.1.1
> The Object class is the root of the class hierarchy.
> The instance methods of the Object class are, therefore, available on
> all objects.
> [JLF] The class methods of the Object class are ???
>
> 5.1.2
> The Class class is like a factory that produces the factories that
> produce objects. It is a subclass of the
> Object class.
> The instance methods of the Class class are also the class methods of
> all classes.
> [JLF] The class methods of the Class class are ???
>
> 4.1.4
> A metaclass is a class you can use to create another class. The only
> metaclass that Rexx provides is .Class, the Class class. The Class
> class is the metaclass of all the classes Rexx provides. This means
> that instances of .Class are themselves classes.
> [JLF] The instance methods of a metaclass are ??? : [proposition] the
> class methods of all the classes associated to this metaclass.
> [JLF] The class methods of a metaclass are ???
>
>
> What is a scope ? (I see scopes and metaClassScopes in the source
> excerpt).
>
> Is there any publication that gives a big picture of this data model ?
> In particular, I try to put in words the actions done by these methods :
> ~instanceMethods
> ~methods
> ~send
>
>
> Source excerpt :
>
> ObjectClass.hpp
> class RexxInternalObject : public RexxVirtualBase{
> inline RexxBehaviour *getObjectType() { return behaviour; }
> -----
> RexxBehaviour *behaviour; /* the object's
> behaviour */
>
> class RexxObject : public RexxInternalObject {
> inline RexxBehaviour *behaviourObject() { return this->behaviour; }
>
>
> RexxBehavious.hpp
> class RexxBehaviour : public RexxInternalObject
> {
> inline RexxTable *getMethodDictionary() { return
> this->methodDictionary; };
> RexxIdentityTable *scopes; /* scopes
> table */
> RexxTable *methodDictionary; /* method
> dictionary */
> RexxClass *owningClass; /* class that created this
> object */
> RexxTable *instanceMethodDictionary; /* methods added via
> SETMETHOD */
>
>
> ClassClass.hpp
> class RexxClass : public RexxObject {
> RexxTable *classMethodDictionary; // class methods
> specific to this class
> RexxBehaviour *instanceBehaviour; // instances of this class
> inherit this behaviour
> RexxTable *instanceMethodDictionary; // methods added to
> this class
> ---------
> RexxClass *baseClass; // Baseclass of this class
> RexxArray *metaClass; // Metaclass of this class
> RexxArray *metaClassMethodDictionary; // Metaclass mdict
> RexxIdentityTable *metaClassScopes; // Metaclass scopes
> ---------
> RexxArray *classSuperClasses; // The superclass and any
> inherited mixins for class behaviour
> RexxArray *instanceSuperClasses; // The superclass and any
> inherited mixins for instance behaviour
> ---------
> RexxList *subClasses; // our list of weak
> referenced subclasses
>
>
> Jean Louis
------------------------------------------------------------------------------
BlackBerry® DevCon Americas, Oct. 18-20, San Francisco, CA
The must-attend event for mobile developers. Connect with experts.
Get tools for creating Super Apps. See the latest technologies.
Sessions, hands-on labs, demos & much more. Register early & save!
http://p.sf.net/sfu/rim-blackberry-1
_______________________________________________
Oorexx-devel mailing list
Oorexx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/oorexx-devel