Larry Wall skribis 2005-05-06 11:07 (-0700):
> But then how do you know if you just want to pass one as a scalar and
> not iterate it?

Assuming =:

     =iterator     # the iterator itself, passable (autoreffing)
    $=iterator     # get one element
    @=iterator     # get remaining elements, lazily

This would mean we'd get

    for @=$fh -> $line { ... }

or

    =it := =$fh;  # =it := $fh.it  # =it = $fh.it  # I dunno.
    for @=it -> $line { ... }

Ugly.

Another alternative would be

    $fh.it   # the iterator itself, passable
    =$fh     # synonym for $fh.it.next, where a real iterator has .it
             # returning $self, so that =$iterator and =$handle both
             # work, without special magic.


Juerd
-- 
http://convolution.nl/maak_juerd_blij.html
http://convolution.nl/make_juerd_happy.html 
http://convolution.nl/gajigu_juerd_n.html

Reply via email to