in reply to Calling Madness

No, not quite.

You have to accept:

PKG::safe_sub( "PKG", $other_args);
as the same as:
PKG::safe_sub( $other_args); safe_sub PKG $other_args;

Also I think you want

shift if ref $_[0] eq "PKG" or $_[0] eq "PKG";
as your test.

Replies are listed 'Best First'.
Re^2: Calling Madness
by Aristotle (Chancellor) on Sep 15, 2002 at 08:10 UTC
    ref $_[0] eq "PKG"
    That will break inheritance, though. You really need UNIVERSAL::isa there instead, like in broquaint's post.

    Makeshifts last the longest.

      As Aristotle says, ref $_[0] eq "PKG" will break inheritance.

      I think that illustrates a serious problem with the concept. I took the stance that:
      Class::derived( $not_blessed); should do the same as:
      $class->derived( $not_blessed); and decided that inheritance was not allowed because the first form was desired.

      If allowing naive users to use the various calling conventions
      was the idea, and why else, I thought this was the clear choice.

      The following, and more, need to be considered:

      Class::derived( $class_obj); # Jack Class::derived( Class $not_blessed); # Queen Class->derived( $not_blessed); # King $class_obj->derived( $not_blessed); # Ace Class::derived( "Class", $not_blessed); # Joker

      The last is the joker. How will you distinguish between the Joker and the Queen?
      And what about Jack? Is that the same as:  $class_obj->derived;
      or the same as:  $class_obj->derived( $class_obj);

        Class::derived($class_obj) is the same as $class_obj->derived() except it disables late binding.

        Makeshifts last the longest.