At 10:36 AM -0700 8/28/02, Larry Wall wrote:
>On Wed, 28 Aug 2002, Deven T. Corzine wrote:
>: I'm not saying we should dump the operators -- if we get more power by
>: assuming a backtracking implementation, maybe that's a worthwhile tradeoff.
>:
>: On the other hand, if we can keep the implementation possibilities more
>: open, that's always a worthwhile goal, even if we're not sure if or when
>: we'll ever take advantage of those possibilities, or if we even could...
>
>That is a worthy consideration, but expressiveness takes precedence
>over it in this case. DFAs are really only good for telling you
>*whether* and *where* a pattern matches as a whole. They are
>relatively useless for telling you *how* a pattern matches.
>For instance, a DFA can tell you that you have a valid computer
>program, but can't hand you back the syntax tree, because it has
>no way to decide between shifting and reducing. It has to do both
>simultaneously.
While true, there are reasonably common cases where you don't care
about what or where, just whether. For a set of mushed-together
examples:
while (<>) {
last if /END_OF_DATA/;
$line .= $_ if /=$/;
next unless /$user_entered_string/;
}
Sure, it's a restricted subset of the stuff people do, and that's
cool. I'd not even want to put in DFA-detecting code in the main
regex compilation grammar. But in those cases where it is useful, a
:dfa switch for regexes would be nifty.
(Though *please* don't yet--we've not gotten the current grammar
fully implemented :)
--
Dan
--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk