develooper Front page | perl.perl5.porters | Postings from February 2012

Re: [perl #109744] referenced constant loses readonlyness

Thread Previous | Thread Next
From:
Zefram
Date:
February 3, 2012 08:59
Subject:
Re: [perl #109744] referenced constant loses readonlyness
Message ID:
20120203165901.GA17616@lake.fysh.org
Father Chrysostomos via RT wrote:
>It's necessary so that ops with TARG appear to return a different value
>each time.  The abstraction leaks badly, though.  See #78194.

It's tempting to write a module that replaces *every* const op with
my identity-preserving variant.  But that'd break stuff that expects
(reasonably) to pull the SV directly out of const ops that it created.

I think the workaround that I need at this point is a function that
generates a fresh readonly scalar (with specified value), doesn't wave it
anywhere near a pad, and returns a ref to it.  You could replace "\123"
with "readonly_scalar(123)" where needed to initialise a Lexical::Var or
to assign to a glob.  Thing is, I already figured I need such a function,
for situations where the desired value doesn't otherwise come in readonly
form (e.g., readonly_scalar([])).

-zefram

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