http://qs321.pair.com?node_id=172128


in reply to Apocalypse 5 and regexes

There's one thing that bugs me in the page on modifier reform, and that's the syntax for specifying when to match.

and I quote:

A modifier that starts with a number causes the pattern to match that many times. It may only be used outside the regex. It may not be bundled, because ordinals are distinguished from cardinals. That is, how it treats those multiple matches depends on the next character. If you say

s:3x /foo/bar/

then it changes the first 3 instances. But if you say

s:3rd /foo/bar/

it changes only the 3rd instance. You can say

s:1st /foo/bar/

I love the concept, but I'm not too keen on the use of 1st, 2nd, 3rd, 4th... I think it's just a bit too clever for its own good. Wearing my programmer's hat, I would rather see a more generic method. Here, 1, 2 and 3 are exceptions. It's not until 4 that the pattern repeats. Wearing my linguist's hat, at least for the only other language I feel qualified to speak for, French, the pattern is simpler: 1er, 2eme, 3eme... (accents and gender notwithstanding). So by some unit of measure, the chosen syntax is more difficult than it could be.

Knowing the shorthand for cardinals is not one of the simpler things foreign students learn about in English, thus non-English speakers are at more of a disadvantage than for other keywords such as die, split, rename... at least you can find those in a dictionary.

A more linguistically neutral approach would be to use n: 1n, 2n, 3n. It looks more mathematical and ties in with "to the nth degree" thereby retaining some notion of cardinality.

Ok, I admit this is a minor nit, but I did find it quite jarring when I read the Apocalypse.


print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'