[EMAIL PROTECTED] writes:
: To put it another way, no one should ever be tempted to do this:
: 
:     $obj->{'attribute'}
: 
: for efficiency reasons inside a tight loop or what have you.  (And no,
: the solution is not to "use C when you need efficiency."  I shouldn't
: need to use portable assembler to access an object attribute
: efficiently.)  Whatever the syntax turns out to be, simple things like
: object attribute accessors should not only be faster than doing this
: in Perl 5:
: 
:     $obj->attribute
: 
: they should even be faster than the naughty, encapsulation-destroying,
: implementation-revealing hash-lookup above.

Regardless of how fast they go, accessors are in some sense the
"correctest" way to access attributes, since they inherit correctly,
and hashes don't.  And the $obj->attribute syntax (or $obj.attribute syntax)
is much cleaner than any hash-based syntax.

The main downside of accessors is that you can't (currently) say

    local $obj->attribute = 2;

: I don't think pseudohashes and such go far enough.  I don't want "faster
: hash-based objects" or just "faster method dispatch", I want real,
: honest to goodness classes with attributes and methods and such that are
: distinct, both in syntax and implementation, from other Perl data
: structures like hashes and arrays.

I'm not sure we have to throw out the orthogonality of OO to data
structure to get what you want.  And we're certainly not going to
introduce syntax just to have more syntax.  But we do have to add
enough syntax (or metasyntax!) that it becomes possible to turn a
clearly written class into an efficiently implemented class.  And if we
invent a metasyntax that makes this possible, we need to either settle
on a standard syntax/implementation or make sure that variant
syntaxes/implementations will interoperate, particularly under
derivation.

: I think it's important to focus on this so it doesn't get lost in all
: the discussion of new letters to tack onto "m/.../sogie" and new syntax
: for range operators and such ;)  And I think it's something that
: everyone can agree on, since there's a lot of benefit to be had, and no
: down-side that I can see.
: 
: Let's make Perl 6 an awesome language for object-oriented development.

Can't disagree with that, as long as we don't trade away too much for it.

Larry

Reply via email to