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

Re: [perl #109744] referenced constant loses readonlyness

Thread Previous | Thread Next
February 3, 2012 08:59
Re: [perl #109744] referenced constant loses readonlyness
Message ID:
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([])).


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About