On Fri, Jul 13, 2007 at 09:16:59AM -0700, [EMAIL PROTECTED] wrote:
> +++ trunk/docs/pdds/pdd15_objects.pod Fri Jul 13 09:16:58 2007
> @@ -889,9 +889,15 @@
>  =item getattribute
>  
>    $P1 = getattribute $P2, $S3
> +  $P1 = getattribute $P2, $P3, $S4
>  
>  Get the attribute with the fully qualified name $S3 from object $P2 and
> -put it in $P1.
> +put it in $P1. To get an attribute for a parent class that has the same name
> +as an attribute in the child class, pass an optional class object or 
> namespace
> +key $P3 for the parent class.
> +
> +If the attribute doesn't exist, it will throw an exception. If the attribute
> +exists, but the value hasn't been set, it will return an C<Undef> PMC.

A plea for consistency:

For most of the other opcodes in Parrot, looking up a value that 
hasn't been set returns NULL and not Undef.  I think we should
be consistent in this respect for getattribute.

For example, retrieving a keyed value from a Hash or ResizablePMCArray
returns NULL if the value hasn't been set.  Similarly, using get_global
on a symbol that hasn't been set returns NULL.  It makes things a
lot more regular (and perhaps simpler) if getattribute could do the
same.

Also, note that we have get_class, get_global, get_hll_global,
get_namespace, get_name, etc.  Could we add some more consistency
about the use of the underscore?  In fact, a quick 

    grep " get[a-z]" *.pod

seems to indicate that the only other "get" opcodes that don't 
have underscores are "getinterp" and "getprop".  Similar statements
hold for the "set" opcodes.

(Yes, I realize that we also have "addattribute" and 
"removeattribute" that don't have underscores, and so 
getattribute/setattribute should perhaps be symmetric with
those.)


Just some thoughts,

Pm

Reply via email to