develooper Front page | perl.perl5.porters | Postings from October 2003

Re: [PATCH pod/perlfunc.pod] ref can return false on references

Thread Previous | Thread Next
From:
Fergal Daly
Date:
October 6, 2003 15:20
Subject:
Re: [PATCH pod/perlfunc.pod] ref can return false on references
Message ID:
200310062318.32788.fergal@esatclear.ie
On Monday 06 October 2003 15:57, Orton, Yves wrote:
> > It might also be worth mentioning Scalar::Util's reftype() and blessed()
> > which are unambiguous in their functionality and often what people really
> > should be using mean when use ref(),
> 
> Arguably ref() should be deprecated and blessed() and reftype() moved into
> core. isa() is an unsatisfactory means of determing variable type, as is
> ref().

Absolutely. ref() tries to answer 3 questions - is it a ref, what's the 
reftype, what's the class. It only answers the first one reliably and even 
then there's a weird edge case. Getting the correct answer to the other 2 
requires fiddliness.

If the other 2 questions were worth answering in the core then surely they're 
worth answering clearly.

> Also, as the pseudo-class Regexp is actually a core class facilitated by
> magic it should not return SCALAR as its reftype. IMO it should return REGEX
> instead. (And it should be possible to strigify it when blessed without
> reblessing it into the class 'Regexp'. I have a patch for Scalar::Util to do
> this, but its odd to me that the core logic doesnt handle this more
> smoothly.)

All good except could this cause problem if something found a REGEX in 
*{foo}{SCALAR}?

F


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About