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

Formal Parameters To While Block

Thread Next
From:
Joshua Gatcomb
Date:
April 26, 2005 08:24
Subject:
Formal Parameters To While Block
Message ID:
941eab8405042608246270287e@mail.gmail.com
<as it appears the email I sent before subscribing is being held and I
am impatient, I have subsequently subscribed and am resending from a
different address>

All:
Please forgive me, but I have only recently started
following the language side of p6 after spending a
fair amount of time with Parrot.  Last night I
installed Pugs and wrote my first p6 code:

http://perlmonks.org/index.pl?node_id=451398

Reading S04, it seems that there are no implicit
blocks around control structures, so p5 code like:

while ( my @array = $ref->() ) { ... }

would scope my @array appropriately, it will not in p6

The solution is formal parameters.  The trouble is I
can't seem to find a good example in S04 that matches
what I am trying to do.

while $ref() -> @array { ... }

is what I think it might be modeling it after the for
loop, but the closest thing I see in while is:

while =$*IN -> $line {...}

I am happy to write tests to get the appropriate
functionality in Pugs, but I am not sure what is
appropriate???

Cheers,
Joshua Gatcomb
a.k.a. L~R

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