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

[perl #47762] 5.10: different behaviour of duplicated named capturing parens with/without (?|...)

Thread Next
From:
bulk88 via RT
Date:
December 27, 2012 02:08
Subject:
[perl #47762] 5.10: different behaviour of duplicated named capturing parens with/without (?|...)
Message ID:
rt-3.6.HEAD-17500-1356574126-673.47762-15-0@perl.org
On Sat Nov 24 04:49:14 2007, demerphq wrote:
> On Nov 24, 2007 11:01 AM, Rafael Garcia-Suarez
> <rgarciasuarez@gmail.com> wrote:
> > On 24/11/2007, via RT Andrew wrote:
> > > The resetting parens (?| ... ) in regexps wokr wrong when it is
> > > used together with named captures where two of them have the same
> name
> > > but are in different branches of "|".
> >
> > This doesn't look very difficult to fix, but for 5.10.0, since we're
> > in RC mode, it's probably better to document this as a known
> limitation.
> 
> I concur, and actually off the top of my head I can't see an easy
> solution.
> 
> Named captures are implemented as maps to one or more numbered capture
> buffers. And capture buffers in general work by hardmapping an
> open/close regop to a given buffer number, normally a 1:1 mapping,
> except that branch reset bends the rule so that multiple regops point
> at the same buffer. Thus the two are to a certain extent mutually
> exclusive.
> 
>    OPEN1 ---> buffer index
>    NAME1 ---> buffer index
> 
> So what happens is that with the two combined you get something like:
> 
>   open1
> ...
>   open2
> ...
>   open1
> ...
>   open2
> 
> year->1,2
> 
> Thus in the "incorrect case" if the OP dumps $-{year} he should get
> ['november','2007'].
> 
> Without the branch reset the program ends up looking like:
> 
>    open1
> ...
>    open2
> ....
>    open3
> ....
>    open4
> 
> year->1,3
> 
> And thus $+{year} will have the correct value.
> 
> So id say we document this mixture as "probably best avoided, but if
> you cant, consider using $-{year} as a workaround."
> 
> IMO its most definately not something that can be changed in time for
> release.
> 
> yves
> 

5.10 is out of support now. Does anything in this bug still apply today
or can it be closed?

This bug also lists Win32 as the OS due to the perlbug data, but its not
Win32 specific (reason why I found it).

-- 
bulk88 ~ bulk88 at hotmail.com

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

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