* Adam Kennedy <[EMAIL PROTECTED]> [2006-04-07 13:25]:
> Just because I (repeatedly) attack chromatic over
> UNIVERSAL::isa/can nobody should be under the impression that
> using the functions directly is in any way a good thing.
> 
> The only cases for which it's genuinely useful is asking
> "ignoring what you say you are in OO terms, what are you
> actually implemented as underneath".

I still wonder what’s bad about using

    UNIVERSAL::can( $foo, "can" )

as a pre-Scalar::Util-compatible replacement of

    blessed( $foo )
    
that is, purely as a boolean test where only the truthness of the
return value is of interest but the actual reference is not. This
is the only case for which I ever invoke `UNIVERSAL::can` as a
function. (`UNIVERSAL::isa` I never invoke as a function at all.)

Given that all I’m interested in is the truthness of the return
value, the only scenario in which this would be a dumb idea would
be if

    !!UNIVERSAL::can( $foo, "can" )  !=  !!$foo->can( "can" )

holds. The only way for that to hold given

    defined UNIVERSAL::can( $foo, "can" )

is if

    !defined $foo->can( "can" )

is true.

In other words, calling `UNIVERSAL::can` as a function would be
bad if `$foo` responds to a `->can` query… claiming that it has
no `can` method.

Which is absurd.

Hence, I cannot see how calling `UNIVERSAL::can` as a function is
harmful for *this one particular specific case* of inquiring
whether or not a reference can respond to `->can`.

Regards,
-- 
#Aristotle
*AUTOLOAD=*_;sub _{s/(.*)::(.*)/print$2,(",$\/"," ")[defined wantarray]/e;$1};
&Just->another->Perl->hacker;

Reply via email to