Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Re: Re: Re: my versus our in nested regex

by demerphq (Chancellor)
on Oct 18, 2003 at 18:10 UTC ( [id://300314]=note: print w/replies, xml ) Need Help??


in reply to Re: Re: Re: my versus our in nested regex
in thread my versus our in nested regex

Well, these constructs are experimental. Their behaviour is possibly subject to change in 5.10. Recently Abigail-II posted a doc change patch to p5p to have them no longer marked so, and the 5.10 pumpking rejected it on the grounds that it was one of his intentions to sort out a number of issues related to these constructs and that he couldnt guarantee that their behaviou would be unchanged by doing so. So, use the constructs if you wish, but be aware that you are using beta quality code.

PS, im guessing Hugo will try Real Hard to keep them as close to their current behaviour as possible, but given one of his major objectives of 5.10 is massive improvements to the regex engine its anyones guess what will happen. Hugo, if you're reading this, good luck mate. :-)


---
demerphq

    First they ignore you, then they laugh at you, then they fight you, then you win.
    -- Gandhi


Replies are listed 'Best First'.
Re: Re: Re: Re: Re: my versus our in nested regex
by BrowserUk (Patriarch) on Oct 18, 2003 at 18:56 UTC

    The question was more a case of, "I wonder why strict doesn't propogate to regex code blocks?", rather than "Why woudln't 'they' let it propogate?"... but your point is taken. It will be nice to see the extended features legitimised, whatever final form they take.

    I wonder what chance there is of getting a "capture to named vars" contruct added?


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "Think for yourself!" - Abigail
    Hooray!

      I wonder what chance there is of getting a "capture to named vars" contruct added?

      I mentioned it once on p5p, but to a deafenaning silence. It would be lovely though wouldn't it? Although I can see how there might be serious questions about how it should work. What should happen if there are identical named sections? Where should the results be stored? Possibly %+ or something? Also I can see some of the p5p saying "Perl is not going to use the dotNet syntax."

      :-)


      ---
      demerphq

        First they ignore you, then they laugh at you, then they fight you, then you win.
        -- Gandhi


        I think my vision of the way it would work is that a named capture would get stored exactly the same as if

        (...)(?{ $var = $^N })

        That is to say, if a lexical named $var was in scope, it would get the captured string, else a global of that name would. If two blocks named the same var, the second would override the first just as with normal assignment.

        I've no idea what the dotNet syntax is (or even that it had such), but Enlil and I had a discusion about it somewhere a few months ago. Unfortunately, it was tucked down in teh bowels of a thread with an unrelated name, so I can't find it right now.

        Off the top of my head, I think that

        (?$var:...)

        would work. I don't think it would conflict with anything else?

        The one distinction I would make is that if an array was given rather than a scalar,

        (?@array:...){1,10}

        then the captured string would be pushed onto the array. This would allow for captures with repeatition specifiers to do something sensible.

        Perhaps harder to think through is what happens when a regex backtracks through a capture. undef the $var and pop the @array maybe?


        Examine what is said, not who speaks.
        "Efficiency is intelligent laziness." -David Dunham
        "Think for yourself!" - Abigail
        Hooray!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://300314]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-19 23:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found