On Fri, 6 Sep 2002, Mr. Nobody wrote: > While Apocolypse 5 raises some good points about problems with the old regex > syntax, its new syntax is actually worse than in perl 5. Most regexes, such > as this one to match a C float > > /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/ > > would actually become longer: > > /^(<[+-]>?)<before \d|\.\d>\d*(\.\d*)?(<[Ee]>(<[+-]>?\d+))?$/
We've seen this a lot. Many patterns do become longer. But saying that's a flaw is erroneous. Much of the point of A5 was to make patterns *clearer*, not shorter. Your example of the C float in both syntaxes is exactly what we're trying to get away from. Patterns will become readable code, not just line noise. / <[+-]>? [ # Mantissa \d* \. \d+ | \d+ \.? ] <[Ee]> <[+-]>? \d+ # Exponent / That's not as good as it *could* be, but it's better than both of those above. And it's better than the equivilent Perl5 /x pattern. > Therefore I propose a few minor changes: > > character class: [...] > non-captured group: {...} > closure: <{...}> > lookahead assertion: <b ...> > lookbehind assertion: <a ...> > > This would bring the aforementioned regex back down to perl 5 size, and many > would become even shorter than in perl 5. So is your career Golf? Because a lot of people program in Java, even though it takes 7.2e33 lines what would take Perl 13. And a lot of people prefer Java (but not us). Size isn't everything; it's how you use it ;) Luke