Talk:Perl 6 rules

From Wikipedia, the free encyclopedia

[edit] asymmetry in example

The example code for the language  \{ a^n b^n c^n : n \ge 1 \} seems asymmetrical in its requirements, in that it disallows additional trailing cs (<!before c>) but not additional leading as (<!after a>).

I would have expected either that neither constraint be applied, or that both be, or (stronger) that the whole be anchored to start and end of string. Am I missing something? Hv 11:59, 27 February 2007 (UTC)

This is a difference in style between programming examples and pure CS examples. In pure CS, you typically assume that the pattern is "rooted" at the start of the input. Programming languages that implement regular expressions (or rules, in this case) go a step further and re-apply the expression, starting at every token in the input sequence. I'll make a note in the text to clarify this. -Harmil 14:07, 27 February 2007 (UTC)
Actually, you have a point, and in reviewing the text, I realized that you don't need the trailing assertion at all to make the example. For example's sake you don't care about the surrounding context, you just want to match an even number of as, bs and cs. The last example did just that, and thus was different from the first two. No need for that. -Harmil 14:18, 27 February 2007 (UTC)