develooper Front page | perl.perl5.porters | Postings from December 2009

Re: Pod::Abstract 0.19 generating warnings on 5.11.3

Thread Previous | Thread Next
December 28, 2009 10:48
Re: Pod::Abstract 0.19 generating warnings on 5.11.3
Message ID:
On Monday 28 December 2009 at 10:34, Aristotle Pagaltzis wrote:

> What you wou want is this:
>     sub _isa {
>         my ( $val, $class ) = @_;
>         UNIVERSAL::can( $val, 'can' )
>             ? $val->isa( $class )
>             : $class eq ref $val;
>     }
> Here `UNIVERSAL::can( $foo, 'can' )` serves as a no-modules-needed
> replacement of `Scalar::Util::blessed($foo)`, which is the only
> acceptable form of using the `UNIVERSAL` methods as functions IMO.

The problem is more subtle than that.  Using blessed() fails if you want to 
test a class name, not just an object instance...

... and calling can() as a function, not a method is still a hack that 
obscures the intent of the code.  I'd rather see a way to test that a given 
non-reference scalar is a valid class name without relying on side effects of 

-- c

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About