In <20000914020627.B1479@yogi>, Peter Heslin writes:
[...]
:Bart pointed out that it would be more consistent to use the type of
:syntax you have also (unconsciously?) used:
:
:"abcdef...xyz" =~ /(?<=x+)y/

Nothing unconscious about it: I was suggesting that the cleanest way
to add VLLB would be to lift the current fixed-length restriction on
lookbehind.

:rather than the syntax in the RFC, which might be:
:
:"abcdef...xyz" =~ /y(?`=x+)/
:
:It is true that my syntax is weirder, in that the lookbehind comes in
:the middle, or even at the end of the regexp, but it has the advantage
:of letting the programmer decide when the lookbehind should happen.
:This is an advantage rather than a drawback because:
:
:1) it means that the regexp engine *must*, by definition, match the
:`y' in this example before it attempts the lookbehind -- thus the
:O(n^2) behavior is avoided (or at least its avoidance is in the hands of
:the programmer).

Here's an alternative approach to consider: allow the user to override
the optimisation information on a compiled regexp by using re.pm
methods:

  my $re = qr/(?<=x+)y/;
  $re->fixed_string('y', 0); # require a fixed string 'y' at offset 0

which you could then improve (as the regexp engine, I think, can't) to:

  $re->fixed_string('xy', -1);

:I realize that the syntax is weird, but my feeling was that this
:approach would be easier to implement and more useful [...]

I don't think I've seen an example yet that makes clear to me when
and why you'd choose to use this.

I should add, though, that I'm probably too close to the current code
to avoid being quite conservative in the face of proposals that seem
likely to be difficult to reach from where we are now. In reality,
the regexp engine needs a lot of work just to catch up with the rest
of perl as it is now; by the time that is done, the code will look
different enough that I'd probably be reactionary about completely
different things ...

Hugo

Reply via email to