develooper Front page | perl.perl5.porters | Postings from August 2000

Re: how to abort a match branch?

From:
Ilya Zakharevich
Date:
August 5, 2000 12:37
Subject:
Re: how to abort a match branch?
Message ID:
20000805153700.B1537@monk.mps.ohio-state.edu
On Sat, Aug 05, 2000 at 01:31:38AM -0700, Jeffrey Friedl wrote:
> Currently, if you want to abort the current branch, you have to resort
> to hyjinks like
> 	(?(?{ not blah})(?!))
> which is a lot of typing

  (?(?{ blah})|(?!))

> (and eyestrain)

Use custom REx engines to substitute something simpler.

> for what may well be a much more common thing than wanting to pass
> values around in default magic variables during a match.

Do not think so.

> (Along the same lines of utlity vs. eyestrain, I'd love to see a cut
>  operator, such as \V, which looks like a wedge being driven in at that
>  point. Yes, you can do almost everything with (?>...), but this would
>  be so much more readable.

...  But much less understandable.  I still did not see any
explanation what of what \V would do which would not involve backtracking.

>  Actually, I'd like to see two types of cut,
>  \v would be one on the same level as (?>...), while \V would even cut
>  the bump-along the regex engine does if no match can be found at the
>  current position. But, I digress....)

I repeat: even I do not understand what the proposed features are
going to do.  What about less accustomed programmers?

> Hugo's idea is also good, which is to use something like
> 	(?{ if (blah) next })

next *what*?  We need to label pieces of REx, and this labeling should
be orthogonal to "save the match to a named variable".

> BTW, Ilya, the last time that I really looked at perl's regex internals (or
> new externals) was just when 5.003 was comming out in 1996 or so. I guess
> since then you've done a lot of work, to say the least. Peaking at this
> stuff now leaves me in more awe than ever.

No wonder.  Say, the first-char-cognizance code is just a proof of
concept, not something which is for stay.  Nowadays I have no idea why
it works at all.  The logic for or-ing/and-ing pieces should be
substituted by append-ing/and-ing (it may be that only the names
should be changed).  The runtime start-position sniffer was created by
patching, it should be rethought too.

> When I found the super-linear optimization stuff, I
> just shook my head at how it was just so far beyond me.

No wonder.  It is coded wrong.

Ilya



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About