develooper Front page | perl.perl5.porters | Postings from March 2006

Re: CLONE for Tie::RefHash

Thread Previous | Thread Next
From:
Joshua ben Jore
Date:
March 30, 2006 09:02
Subject:
Re: CLONE for Tie::RefHash
Message ID:
dc5c751d0603300902y545f3d52r9d865275951e4888@mail.gmail.com
On 3/29/06, Jan Dubois <jand@activestate.com> wrote:
> On Wed, 29 Mar 2006, demerphq wrote:
> > On 3/29/06, Yuval Kogman <nothingmuch@woobling.org> wrote:
> > > On Wed, Mar 29, 2006 at 12:46:57 +0200, demerphq wrote:
> > >
> > > > overload::StrVal is a fairly slow procedure. Is there a reason why
> > > > Tie::RefHash doesnt use Scalar::Util::refaddr() instead? Its much
> > > > faster.
> > >
> > > It probably relates to it's availability, which is a non issue in
> > > core perl, right?
> >
> > Sorry I missed this point....
> >
> > Scalar::Util is in core since 5.8, and is available for 5.6.
>
> Yes, but refaddr() is new in the core Scalar::Util since 5.8.1, not 5.8.

It'd be easy enough to fail over to overload::StrVal. I added just
such a snippet to Data::Postponed this morning so I could use a fact
function when possible but still work if it wasn't available.

I checked Scalar::Util and it's Changes documents 1.09 as the first
version with the refaddr function.

BEGIN {
    eval "use Scalar::Util 1.09 qw( refaddr );";
    if ( not defined &refaddr ) {
        *refaddr = \ &overload::StrVal;
    }
}

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