My take, based on S05:
On Thu, 2005-05-12 at 10:33, Patrick R. Michaud wrote:
> I have a couple of questions regarding C< :: > in perl 6 rules.
> First, a question of verification -- in
> $rule = rx :w / plane :: (\d+) | train :: (\w+) | auto :: (\S+) / ;
> "travel by plane jet train tgv today" ~~ $rule
> I think the match should fail outright, as opposed to matching "train tgv".
Correct, that's the meaning of ::
S05: "Backtracking over a double colon causes the surrounding group of
alternations to immediately fail:"
Your surrounding group is the entire rule, and thus you fail at that
> In other words, it acts as though one had written
> $rule = rx :w / plane ::: (\d+) | train ::: (\w+) | auto ::: (\S+) / ;
> and not
> $rule = rx :w /[ plane :: (\d+) | train :: (\w+) | auto :: (\S+) ]/ ;
Your two examples fail in the same way because of the fact that the
group IS the whole rule.
> Next on my list, S05 says "It is illegal to use :: outside of
> an alternation", but A05 has
> /[:w::foo bar]/
I can't even figure out what that means. :w turns on word mode
(lexically scoped per S05) and "::" is a group-level commit. What are we
committing exactly? Looks like a noop to me, which actually might not be
so bad. However, you're right: this is an error as there are no
> which leads me to believe that :: isn't illegal here even though there's
> no alternation. I'd like to strike that sentence from S05.
I don't think it should be removed. You can always use ::: if that's
what you wanted.
> Also, A05 proposes incorrect alternatives to the above
> /[:wfoo bar]/ # null pattern illegal, use <null>
> /[:w()foo bar]/ # null capture illegal, and probably undesirable
> /[:w\bfoo bar]/ # not exactly the same as above
No, I think that's exactly the same.
> So, now then, on to the item that got me here in the first place.
> The upshot of all of the above is that
> rx :w /foo bar/
> is not equivalent to
> rx /:w::foo bar/
If we feel strongly, it could be special-cased, but your <null> solution
seems fine to me.
Aaron Sherman <[EMAIL PROTECTED]>
Senior Systems Engineer and Toolsmith
"It's the sound of a satellite saying, 'get me down!'" -Shriekback