develooper Front page | perl.perl6.language | Postings from May 2005

Re: C<::> in rules

Thread Previous | Thread Next
From:
Patrick R. Michaud
Date:
May 13, 2005 22:33
Subject:
Re: C<::> in rules
Message ID:
20050514053429.GA7392@pmichaud.com
On Sat, May 14, 2005 at 04:26:44AM +0000, Luke Palmer wrote:
> On 5/14/05, Larry Wall <larry@wall.org> wrote:
> > I want ::: to break out of *that* dynamic scope (or the equivalent
> > "matchrighthere" scope), but not ::.
> 
> I'm not sure that's such a good idea.  When you say:
> 
>     rule foo() { a* ::: b }
> 
> You know precisely where that ::: is going to take you: right out of
> the rule.  [...] But you're saying that when we use a bare // 
> matching a string, that's no longer the case?  In other words, this:
> 
>     $str ~~ / a* ::: b /
> 
> Is different from:
> 
>     $str ~~ / <foo> /
> 
> That seems like a pretty obvious indirection, and a mistake to break
> it.  There's nothing there except <foo>, how could it act differently?

Because $str ~~ / <foo> / puts the ::: in a subrule, whereas
$str ~~ / a* ::: b / does not.  It's the same sort of difference
that one gets between

    { return if $a; }

and

    sub foo() { return if $a; }

    { foo() }

It's clear that the C<return> in the first case affects control flow in
in the current sub, while the nested C<return> of foo() in the second
case does not.

Pm

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