in reply to Re: perl6 & OO
in thread perl6 & OO

Ovid wrote:

Protected methods in Java can only be used by the class or its subclasses. Trying to prevent a calling program from using them is fairly easy, but it's not built in to Perl.

Actually, protected methods in Java can also be used by classes in the same package. Nevertheless, your point is well-taken. I was working on a project recently where I wished that I had some way of faking protected (and, yes, I am aware of Class::Fields, but that wasn't an option at the time--long story).

Benedictus

Replies are listed 'Best First'.
Re^3: perl6 & OO
by hardburn (Abbot) on Feb 19, 2004 at 20:21 UTC

    "Protected" has a different definition in pretty much every langauge that has it as a feature. It all encompasses the idea that objects that are friends get extra operations on each other. In Perl, you can emulate the feature using caller by checking the package of the code that called you. It's a flexible solution (you get fine-grained control over who gets to call you and who doesn't), but it can get sloppy fast.

    ----
    : () { :|:& };:

    Note: All code is untested, unless otherwise stated