develooper Front page | perl.perl6.language | Postings from April 2006

Re: S5 - Question about repetition qualifier

Thread Previous | Thread Next
From:
Markus Laire
Date:
April 26, 2006 03:00
Subject:
Re: S5 - Question about repetition qualifier
Message ID:
67d53e40604260300y5152f120r50e683870e6bee95@mail.gmail.com
On 4/26/06, Joe Gottman <jgottman@carolina.rr.com> wrote:
> According to Synopsis 5, the repetition qualifier is now **{.} where the .
> must correspond to either an Int or a Range.  This seems rather restrictive.
> Why are we not allowed a junction of Ints, for instance

S05 also says:
<quote>
It is illegal to return a list, so this easy mistake fails:
     / [foo]**{1,3} /
(At least, it fails in the absence of use rx :listquantifier, which is
likely to be unimplemented in Perl 6.0.0 anyway).
</quote>

So it seems only reason not to allow lists is that they aren't yet
implemented, and likely won't be for some time.

> Also, I don't know exactly what the syntax looks like, but I can imagine
> using a repetition qualifier that takes a closure of some sort, for instance
> to match an odd number of repetitions
> m/^ a**{($_ % 2 == 0)} $/; #I'm not sure about the syntax for the code.

Are you reading some old version of S05?
http://dev.perl.org/perl6/doc/design/syn/S05.html says that "The
repetition specifier is now **{...} for maximal matching, with a
corresponding **{...}? for minimal matching. Space is allowed on
either side of the asterisks. The curlies are taken to be a closure
returning an Int or a Range object. "

So you can just put any closure which returns Int or Range directly
within the curlies.

--
Markus Laire

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About