On Fri, Aug 13, 2010 at 08:21:17PM +0100, Ben Morrow wrote: > Quoth rjk@tamias.net (Ronald J Kimball): > > Perhaps someone will write a regex generator that allows the user to > > specify which options are on and which are off. Disallowing (?.-i: means > > the program would have to keep track of which options were off by default. > > > > The program would also have to be updated each time a new option was added > > to the language. > > *NO*. > > (Is this really that hard to understand, or am I just explaining it > badly?) I think you misunderstood my point. That is all one paragraph, discussing a program that generates regular expressions. Suppose I have a program that generates regular expressions, using the (?. syntax, like this: my @options_on = qw/ s a /; # where a and b are hypothetical options my @options_off = qw/ i b /; # that are on by default my $pattern = "whatever"; my $regex = "(?." . join('', @options_on) . '-' . join('', @options_off) . ':' . $pattern . ")"; That wouldn't work under your proposal where (?.-i: is disallowed, because it produces (?.sa-ib:whatever) Instead, it would have to be something like: my %default_on = map { $_ => 1 } qw/ a b /; my %default_off = map { $_ => 1 } qw/ i m s x /; my @options_on = qw/ s a /; # where a and b are hypothetical options my @options_off = qw/ i b /; # that are on by default my $pattern = "whatever"; my $regex = "(?." . join('', grep !$default_on{$_}, @options_on) . '-' . join('', grep !$default_off{$_}, @options_off) . ':' . $pattern . ")"; which produces (?.s-b:whatever) Furthermore, this program would have to be updated each time a new option is added to the language, including it in %default_on or %default_off as appropriate. > The whole point is that you *don't* have to keep track of which flags > are off by default. Any flags you don't specify will be 'off', including > flags you don't know about because they haven't been added to perl yet. If you disallow disabling flags that are off by default, then you *do* have to keep track of which flags are off by default, because you have to know which flags you're allowed to disable and which you're not. RonaldThread Previous | Thread Next