(I'm just studying the intricacies of Perl 6, so please correct me if
i say something stupid or if this has already been discussed before.)

I was looking for the Perl 6 equivalent of

"aaa" =~ /a{1,3}/

and finally found that it's

"aaa" ~~ /a**{1 .. 3}/

This looked rather weird, so i asked on IRC what is the mnemonic for it:
http://moritz.faui2k3.org/irclog/out.pl?channel=perl6;date=2007-06-29#id_l602

I got the reply that it is similar to exponentiation of variables in math:

a ** 5 == a * a * a * a * a == aaaaa

It makes sense after it is explained and i do like the rationalization
of the range as a list-like range, instead of the comma, but the **
syntax is rather ugly to my taste. Seeing that the ** quantifier is
not yet implemented anyway, I thought what could replace it, and the
best i could find was <1 .. 3>.

My rationale is this:

* It looks clean.

* It the chapter about Extensible metasyntax (<...>) in S05 most
paragraphs begin by "A leading X means yadda yadda", where X can be:

   * whitespace
   * alphabetic character (not alphanumeric!)
   * ? $ :: @ % { & [ + - . ! ~~

... so numbers are not covered.

* As a side effect, * is a shortcut for <0 .. Inf>, + is a shortcut
for <1 .. Inf>, ? * is a shortcut for <0 .. 1>.

* The ? of non-greediness can come before the closing > - <1 .. 3 ?>

Any comments?

--
Amir Elisha Aharoni
my band: http://www.myspace.com/tzabari/
my blog: http://aharoni.wordpress.com/

Reply via email to