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

[perl #24237] @& doesn't set PL_sawampersand

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
January 11, 2012 08:36
Subject:
[perl #24237] @& doesn't set PL_sawampersand
Message ID:
rt-3.6.HEAD-14510-1326299777-1985.24237-15-0@perl.org
On Wed Jan 11 08:28:15 2012, sprout wrote:
> On Wed Jan 11 04:32:41 2012, demerphq wrote:
> > On 11 January 2012 13:30, demerphq <demerphq@gmail.com> wrote:
> > > On 10 January 2012 22:31, Father Chrysostomos via RT
> > > <perlbug-followup@perl.org> wrote:
> > >> On Mon May 10 10:30:38 2010, chorny wrote:
> > >>> Same result on 5.12.0, but I'm not sure that it is worth fixing.
> > >>
> > >> Fixing it is quite trivial.
> > >>
> > >>>
> > >>> On Fri Oct 17 13:24:08 2003, grazz@pobox.com wrote:
> > >>>
> > >>> >
> > >>> > If you use (for example) @& before using $&, then $& loses
> > >>> > its magic.
> > >>> >
> > >>> >     % perl -le '"foo" =~ /.*/; print "[$&]"'
> > >>> >     [foo]
> > >>> >
> > >>> >     % perl -le '@&; "foo" =~ /.*/; print "[$&]"'
> > >>> >     []
> > >>> >
> > >>> > This worked correctly in 5.6.1 -- but of course the old
> behavior
> > >>> > wasn't ideal either, since it set PL_sawampersand
> unnecessarily.
> > >>> >
> > >>> >    http://xrl.us/xk7
> > >>> >
> > >>
> > >> As Andreas König mentioned, it was change #11863.  That’s
> > b4a9608f33 in
> > >> git.  The commit message also refers to this thread:
> > >>
> >
>
<http://www.nntp.perl.org/group/perl.perl5.porters/;msgid=Pine.GSO.4.21.0109031235240.7601-
> > 100000@crusoe.crusoe.net>.
> > >>
> > >> As for fixing this: Basically we have two places in
> > gv_fetchpvn_flags
> > >> that add magic to stuff.  The usual place, at the end of the
> > function,
> > >> applies when the typeglob is being created to begin with.  The
> > other
> > >> place, further up, adds magic to things being fetched from
> existing
> > >> typeglobs.  It currently only covers %+, %-, %!, $] and @ISA
> (from
> > >> memory, without looking).
> > >>
> > >> Adding $& $` $' to that section is easy.  And also, the usual
> code
> > path
> > >> that sets PL_sawampersand should still magicalise $& even when
> > creating
> > >> the *& glob for the sake of @&.
> > >>
> > >> This has been done with commit a289ef89aea.
> > >
> > > I kinda wish this had NOT been done. It was not a true regression.
> > In
> > > fact arguably mentioning or using @& should not trigger
> > > PL_sawampersand, which is only supposed to be triggered by use of
> $`
> > > $& $'.
> >
> > On the other hand, i suppose if this is the only sane way to ensure
> > the $& has the right magic then I guess it makes sense.
> 
> Did you look at the code?  @& still doesn’t set PL_sawampersand, but
> neither does it prevent $& from setting it any more.
> 
> And what do you mean by ‘true regression’?  For $& to stop working
> because some script decided to use @& seems like a regression to me.

And BTW, I’d like to get rid of this PL_sawampersand madness (thereby
closing about 6 RT tickets), but my first attempt failed, and my second
attempt is awaiting a response from Nicholas Clark on the status of
PERL_OLD_COPY_ON_WRITE.

(And that reminds me: it’s not just /p that looks to me like a bug
workaround, but also SelectSaver.pm.)

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: resolved
https://rt.perl.org:443/rt3/Ticket/Display.html?id=24237

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