Larry Wall <[EMAIL PROTECTED]> wrote:
> $x is visible only in the rest of the lexical scope.  In contrast,
> $_y would presumably still be visible if the class were reopened.

This strikes me as an exceedingly bad idea.

Encapsulation is a very good thing, and I'm glad it's being added to
Perl 6.  But once in a while, you really *do* need to break
encapsulation.  Maybe a shortsighted module author didn't add an
accessor you need, or maybe you're doing something highly magical for
(e.g.) debugging.  In any case, though, you'll need an escape hatch,
and I really think extending a class should be it.  By extending a
class, you're explicitly saying "I'm going to butt into your affairs";
at this point, if you're not sure what you're doing, you're probably
going to mess things up *anyway*.

(If not this, I at least would like to see a way to make roles and/or
class extensions optionally merge their namespace with the class
they're being composed into; a simple 'is merged' on the
role/extension's definition might do.)

Also note how subtle this point is (it's about the only point I didn't
get from the original message); the degree to which it requires the
class's programmer to predict how others might want to extend his
class; and the syntactic kludge required to specify it (namely, the
sometimes-magical underscore).  I really think this is a very fine
distinction, which programmers will get wrong half the time, and which
you don't even have enough syntax to cope with *anyway*.

-- 
Brent 'Dax' Royal-Gordon <[EMAIL PROTECTED]>
Perl and Parrot hacker

Reply via email to