John Siracusa wrote:

> Object attributes should be accessed through accessors that look and behave
> like accessors:
> 
>     $name = $mage->name;


and Object qualifiers should be accessed through accessors that look like
qualifiers:

        $mage : (HASHTYPE = 'packed_static')

 
> I'd like to see a *distinct syntax and implementation* for objects. (The
> following example is just off the top of my head and is not meant to be a
> syntax recommendation, but the spirit is there.)


I don't mind if they behave like key-value pairs, as long as they are
really packed structures internally.  I want to load in raw C++ headers
with C<require> and have all structures and classes become defined in the
current package. (RFC 61 version 2)  

        Thing.OUTER.inner.which 

will become 

        $$$Thing{OUTER}{inner}{which}

but that is all right as the compiler will still turn that into an access to
the seventh and eighth bits in the 57th byte from the beginning of the structure
and print it out in STRING context as 'RED' 'GREEN' or 'BLUE' which are the
enumerated types associated with that field.



> Classes should be called classes, not packages.  We could even keep packages
> and the whole Perl 5 o-o implementation around.  It won't interfere with
> Perl 6 o-o because Perl 6 o-o does not dress up and overload normal data
> structures to make "objects."  So yes, it should be:
> 
>     class Person;
> 
> Same deal with methods.  Subroutines are subroutines and methods are
> methods.


>  Let's say we want to do more than set/get the name attribute via a
> single scalar:
> 
>     method name
>     {
>       my($first, $last) = @_;
> 
>       $self.name = $first . ' ' . $last;
>     }
> 
> Here we see an implicit $self (available in all methods), normal arg
> handling via @_ (with the 0th arg no longer being a ref to self), a new
> syntax for accessing attributes inside custom methods of the same name
> ($self.name), and an implicit return of the name attribute (did I mention
> that get/set should return the current/new value of an attribute?)

cool, very cool.

Reply via email to