in reply to Inconsistent for the sake of convenience
If you want a better convenient inconsistent regular expression behavior, ask yourself why the following are not endless loops:
In both cases shouldn't the pattern match before f, then before f, then before f...? See perlre for an explanation. You probably understood the explanation there if you see why pos($string) = pos($string) is not a no-op.@matches = ("foo" =~ /o?/g); my @chars = split //, "foo";
An inconsistency that I like is the (now useless) feature that the line "nose hairs"; generates a warning but "ignore my nose hairs, please"; does not. See How to make warnings disappear for further discussion and an explanation. It also explains why the feature has been useless since before I learned Perl.
If you want a lot more inconsistency for the sake of convenience though, consider how context works in Perl and look how core parts of the language such as localtime, grep, and @array behave depending on context.
And one general thought for this thread. As you review these examples, ask yourself whether it is a coincidence that Larry Wall was a repeat winner of the International Obfuscated C Contest? Or that his 1986 win was in the category Useful Obfuscation?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Inconsistent for the sake of convenience
by Porculus (Hermit) on Feb 17, 2009 at 21:06 UTC |