in reply to Private and Protected class methods

I haven't had much call for protected methods. What is the problem with this?
package Parent; sub protected_sub { my $me = shift; die unless $me->isa(__PACKAGE__); print $me, " -> Parent::protected_sub$/"; }
Be well,
rir

Replies are listed 'Best First'.
Re^2: Private and Protected class methods
by chromatic (Archbishop) on Sep 07, 2006 at 05:14 UTC
    What is the problem with this?

    Calling isa() and forcing inheritance sucks.

      Why? I mean, I can see the argument for not using protected subs at all, but given that it's a requirement, and that the point of "protected" is that the class and its children (thus, inheritence is implied) can call it, what's the issue with that approach?

      <radiant.matrix>
      A collection of thoughts and links from the minds of geeks
      The Code that can be seen is not the true Code
      I haven't found a problem yet that can't be solved by a well-placed trebuchet

        Sure, if you have to use inheritance throughout your system and absolutely cannot use any other method of code reuse or polymorphic structure, obviously inheritance is the way to go. That's a little bit circular; this coding style makes inheritance necessary by forbidding the other approaches.

        My point is that I think that's a silly, harmful assumption, nearly as bad as saying that your identifiers cannot use the letter e. isa and ref are code smells to me.