Okay, here's another shot at the semantics for objects. If folks, especially non-perl folks, would look this over and chime in, I'd much appreciate it.


Objects have (all optional):


*) Properties
*) Methods
*) Attributes

Properties are global to the object. An object can have only one propery named "foo".

Attributes are local to a class in an object's inheritance hierarchy. An object can have one "foo" attribute per class in its inheritance tree.

Attributes are considered class-private, so a class will normally only see its own attributes. There will be a mechanism to see all the attributes for an object, though. Code outside a class won't see the attributes--they aren't exposed.

Methods override properties, so if an object has a method "foo" and a property "foo", then accessing object.foo will call the method. (Methods may be lvalue)

Code can ask for an explicit method handle, basically "give me a PMC for the method named "foo" on this object" which can be called later. Changes to a class's "foo" method won't affect "foo" method handles already returned.

Methods can be redispatched, as well as dispatched. Redispatching continues on following the class hierarchy. Methods do not have to do this, but they may.

Classes that inherit via delegation, for example a Python or Perl 6 class that inherits from a perl 5 class, store away the object that's being delegated and tack a property on it that links to the parent object. That way when a delegated method redispatches, or calls another method on the delegate object, the original object is available to dispatch properly.

Classes may be responsible for delegating to child classes, though this can be left automatic.

All of these--method lookup, property lookup, attribute lookup--may be intercepted, and all may have a fallback method that's called if the 'proper' lookup fails.


I think this about covers it. If there's missing semantics, and I expect I missed something, let's get it out and add it. Once we've got it pretty much nailed I'll spec out the interface and we can start in on the implementation.
--
Dan


--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
[EMAIL PROTECTED]                         have teddy bears and even
                                      teddy bears get drunk

Reply via email to