develooper Front page | perl.perl5.porters | Postings from April 2001

Re: [PATCH] UNIVERSAL shouldn't require Exporter

Thread Previous
Graham Barr
April 26, 2001 02:03
Re: [PATCH] UNIVERSAL shouldn't require Exporter
Message ID:
On Thu, Apr 26, 2001 at 04:54:17AM -0400, barries wrote:
> On Thu, Apr 26, 2001 at 07:05:10AM +0100, Graham Barr wrote:
> > There should not be an import{} method at all.
> Cat's out of the bag on this on, I think.  Quoth perlobj:
>      `isa' is also exportable and can be called as a sub with two argu-
>      ments. This allows the ability to check what a reference points to.
>      Example
> 	 use UNIVERSAL qw(isa);
> 	 if(isa($ref, 'ARRAY')) {
> 	     #...
> 	 }
> It can be handy to be able to call isa() and can() without worrying if
> the "object" is blessed.  Why shouldn't isa() be imported, anyway?

Ah yes, I forgot about that one. Now if calling methods on unbless refs was
allowed we could avould the whole problem.

But isa() also sufferes from the same problem as ref(), that is it does
not differentiate between the type of the reference and the package.

That was why I added reftype() and blessed() into Scalar::Util, which
Jarkko has now added to the core.

So, IMO, if you are testing for the type reftype() would be a better choice.

But then again, history will always require isa to be Exportable


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