Calling UNIVERSAL::can() as a function is allowed. (was: [OT] best way to determine existence of a function in a package)

Jonathan Stowe jns at gellyfish.com
Wed Nov 21 20:47:32 GMT 2007


On Wed, 2007-11-21 at 19:17 +0000, Andy Wardley wrote:
> Matt S Trout wrote:
>  > You should never, ever, EVER use any UNIVERSAL::* as a function. That's not
>  > what it's for, not how it's designed to work and can seriously fuck things
>  > up.
> 
> I'm sorry, but you're wrong.
> 

Quite.

UNIVERSAL::isa() as a function is a perfectly sensible way of
determining whether a reference you have been handed is of the type that
you require. Of course you could check with Scalar::Util::blessed()
first and then call isa as a method but then why bother. I know where I
can find languages with strongly typed method signatures.

/J\


More information about the london.pm mailing list