"Abhijit A. Mahabal" <[EMAIL PROTECTED]> writes:

> There is another problem beyond efficiency: the P6 list semantics is lazy.
> 
> The following is valid P6, AFAIK:
> 
> for 1 .. Inf {
>   print $_;
>   last when 10;
> }

Yeah, but that's a foreach loop, despite the fact that "foreach" is
spelled "for" in your example.  foreach loops have a different
signature from for loops.  (P6 does make it possible to have two
routines with the same name that differ by signature, right?  ISTR
seeing something about that in one of the Apocalypses[1].)

> And then most of the proposed methods (including popping off [EMAIL PROTECTED])
> would not work.
  
foreach loops take their only code block in the braces; you don't have
the code block inside the parens to worry about in that case, like you
would in a for loop.  Thus, foreach loops are no harder to implement
than while or if, signature-wise.

> my_for 1 .. 5 { something }
> 
> and not have to write:
> 
> my_for 1 .. 5 {something };

Ah, that's another matter, but you need that to implement while and if
as well.  Methinks that a signature should be able to call for a code
block in braces, and when it's called the signature after that code
block should be optional.  (And it needs to be optional whether the
code block is the last thing in the signature or not; else, how would
one implement map and grep and sort?)

A question I haven't fully thought through:  should a closing brace
_ever_ need to be followed by a semicolon?  Because, if not, then we
could do this...

my $foo = sub { do_stuff() } # <-- Note no semicolon..
my $baz = {
   my @bar;
   more_stuff(@bar)
   yetmorestuff(@bar)
   [EMAIL PROTECTED] }                   # <-- Here also.

Would that have any nasty consequences I haven't thought about?

--- 

[1] I _think_ that's the right plural.
    
    *apocalupt + s + es => apocalupses, transliterated apocalypses.
    But my third declension is a little rusty and I'm not certain
    about that first s being added to the root to form the noun stem.
    
    It's a sufficiently unusal word imported to English recently
    enough that the plural would be formed like in the original
    language, yes?  But then why isn't the singular "apocalypsis"?
    
    Fooey, English is weird, let's stick with Perl.
     
-- 
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
split//,"[EMAIL PROTECTED]/ --";$\=$ ;-> ();print$/

Reply via email to