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

Re: [perl #70043] Re: [Sysadmins] Perl allows non-sensicaloperations on reference converted to an integer

Thread Previous | Thread Next
From:
Abigail
Date:
October 27, 2009 04:35
Subject:
Re: [perl #70043] Re: [Sysadmins] Perl allows non-sensicaloperations on reference converted to an integer
Message ID:
20091027113517.GE24654@almanda
On Tue, Oct 27, 2009 at 07:27:01AM -0400, David Golden wrote:
> On Tue, Oct 27, 2009 at 7:21 AM, Abigail <abigail@abigail.be> wrote:
> > I use often stringified references. Either by printing them (debugging
> > tool), or as hash keys. If I want a quick and dirty implementation
> > of inside out objects and I'm using a pre-5.10 perl, I use objects
> > as keys keys directly.
> >
> > Forbidding anything that may lead to an error somewhere else in the
> > code would quickly leave us with no construct in the language at all.
> 
> Fortunately, you'd still be able to do so in pre-5.10 perl.  :-)
> 
> Making reference stringification a warning wouldn't stop quick and
> dirty debugging, which is why I say that would, at a minimum, be an
> improvement on the current situation.
> 
> I might be in favor of refaddr() moving into core from Scalar::Util so
> it's always available even if module loading is borked.


Ah, but perhaps

    $hash {refaddr $ref}

should warn as well, because it's a disaster waiting to happen. You know,
in a thread, the address might change. And post 5.10, you have fieldhashes,
which you should use instead of refaddr anyway.  ;-)


Abigail

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