cvsuser 03/03/18 13:49:26
Modified: docs/pdds pdd15_objects.pod Log: More Updates Revision Changes Path 1.6 +117 -8 parrot/docs/pdds/pdd15_objects.pod Index: pdd15_objects.pod =================================================================== RCS file: /cvs/public/parrot/docs/pdds/pdd15_objects.pod,v retrieving revision 1.5 retrieving revision 1.6 diff -u -w -r1.5 -r1.6 --- pdd15_objects.pod 12 Mar 2003 14:42:16 -0000 1.5 +++ pdd15_objects.pod 18 Mar 2003 21:49:25 -0000 1.6 @@ -73,14 +73,12 @@ Please see the glossary for definitions of the various terms. -=head1 IMPLEMENTATION - -=head2 Objects +=head2 Object interfaces -Objects must do the following things. Note that these are required of -PMCs in general, but objects are presumed to actually do something -useful with these things rather than just (potentially) throwing an -exception. +Objects must present the following interface to the outside +world. Note that these are required of PMCs in general, but objects +are presumed to actually do something useful with these things rather +than just (potentially) throwing an exception. Any PMC that meets these criteria can be considered an object. Objects do I<not> have to have corresponding classes, though it's a fairly @@ -91,22 +89,133 @@ =item Get and set properties Strictly speaking, getting and setting properties is a PMC thing -rather than an object thing, as PMCs are +rather than an object thing, as PMCs are all capable of having +properties. Nevertheless, properties are put into the object bag, as +many systems use properties to note object attributes. + +Note that methods and properties may share a namespace, depending on +the language backing the PMC. Generally methods override properties, +so doing a get or set of a property on an object that has a method of +the same name will call that method in rvalue or lvalue context, +respectively. =item Get a property hash +Returns a hash PMC with all the properties and their values in +it. This generally should have no activity associated with it, and be +a plain key/value hash. Usually used for introspective purposes. + =item Call a method +Methods are called by name. The object's method dispatch vtable entry +is responsible for doing the actual method dispatch, in whatever way +it deems necessary. + +Note that it is perfectly acceptable, and common, for methods and +properties to share a namespace, with the methods overriding the +properties. That is, you may fetch property "foo", but if there is a +method "foo" as well, the return value will be the return from method +"foo" rather than property "foo". This behaviour is not required, however. + =item Get a method PMC +This returns a method PMC for the named method, which can be called +at a later time. This may return a "no method" PMC which throws an +exception if the object is unable to return a method PMC. + +This PMC should be for the I<current> definition of the method. If +the method later changes, this method PMC should not be +affected. (Wrapping the method doesn't count, as wrapping methods and +subs is considered an in-place activity) + =item Check if a PMC can perform a method +Checks, by name, to see if the PMC can perform the method. + =item Check if a PMC implements an interface +Checks to see if the PMC can implement the interface + =item Check if a PMC is a member of or child of a class +Checks to see if the PMC is a member of, or child of, a +particular class. + +=back + +=head2 Object internals + +Parrot's standard object is based around an attribute container, +essentially an array of attributes. Any object tagged with the +C<is_base_object> bit can be assumed to ultimately be derived from +this base object, and thus behave like a base object. If the bit's +not set, it's not safe to assume so. + +=head2 Classes + + +=head1 IMPLEMENTATION + +Note that because this describes the "blessed" parrot object system, +we snag flag bits. Nyah. [Note to self: Remove this when the PDD goes final] + + +=head2 Flag bits + +=over 4 + +=item is_delegate + +If the is_delegate bit is set in the PMC's header, the object is a +delegate of a parent object, and the method call should be made on +the parent instead. + +Generally this bit will only be used if the method dispatch vtable +entry doesn't already know whether the PMC it's part of is a delegate +object or not. + +The correct behaviour is, when doing a method call on this PMC, to +find its __PARENT property, which has the PMC for the parent PMC, and +dispatch to that instead. + +=item is_base_object + +If set, the PMC is ultimately derived from Parrot's base object type, +the attribute container class. + =back +=head2 Properties + +The following are 'reserved' object properties. In general the +interpreter reserves anything with a leading double-underscore, but +that's a matter for another PDD. + +=over 4 + +=item __PARENT + +Object property. The value is the PMC for the parent object, the one +encapsulating this one. + +=item __IS + +Class property. An array of the immediate superclasses. + +=item __GRANDS + +Class property. An array of I<all> the super classes, flattened, in +search order. + +=item __HAS + +Class property. An array of the interfaces this class implements. + +=back + +=head2 Object Interface + +=head2 Object guts =head2 Classes
