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:
Yitzchak Scott-Thoennes
Date:
October 6, 2003 23:42
Subject:
Re: [PATCH pod/perlfunc.pod] ref can return false on references
Message ID:
20031007064135.GB1464@efn.org
On Mon, Oct 06, 2003 at 03:57:30PM +0100, "Orton, Yves" <yves.orton@de.mci.com> 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().

One awkward difference is that ref returns '' for a non-reference while
reftype returns undef.
 
> 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.)

That last part was fixed in 5.8.1 and blead.

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