As I was playing around with dirhandles, I thought "What if..." (which
is actualy sorta fun to do in Pugs, where Perl 5 has everything
documented somewhere even if nobody has read it).

My goal is modest: explain fewer things in the Llama. If dirhandles
were like filehandles, there's a couple of pages of explanation I don't
need to go through.

Witness:

I can iterate through the elements of a named array with [EMAIL PROTECTED]:

   my @a = < 1 2 3 4 5 >;
   for [EMAIL PROTECTED] { .say }   # but not =< 1 2 3 4 5 > :(

and I can read lines from a file:

   for =$fh { .say }

Should I be able to go through a directory handle that way too? A "yes"
answer would be very pleasing :)

   my $dh = "doc".opendir;
   for =$dh { .say }    # doesn't work in pugs

And, since we're using objects now, .closedir can really just be
.close, right? 

And, maybe this has been already done, but wrapping a lazy filter
around anything that can return items. I'm not proposing this as a
language feature, but if many things shared the same way of getting the
next item, perhaps I could wrap it in a lazy map-ish thingy:

   my $general_iterator = lazy_mappish_thingy( "doc".opendir ); 

   for =$general_iterator { .say }

   $general_iterator.close;  # or .end, or .whatever

That last part is definetely not Llama material, but maybe I'll at
least hit the haystack.

Reply via email to