On Thu, Sep 09, 2004 at 09:27:36AM -0700, David Wheeler wrote: : On Sep 9, 2004, at 9:14 AM, Larry Wall wrote: : : >I just borrowed the -> from Perl 5 because I knew it was available, : >and I thought it read better for C<for> loops than the Ruby approach. : : Interestingly, I was at PDX.pm last night for a presentation entitled, : "Ruby for Perl Programmers." One of the things that the presenters said : was typical idiomatic Ruby was the use of blocks (I think that's what : they called them) with iterators, such that you almost *never* see the : use of C<for> in Ruby. : : Might a similar thing happen with Perl 6 code blocks and iterators?
That is basically what the thread "Revision of A12's lookahead notions" was all about, though perhaps it didn't look like it on the surface. The upshot of which was that if you want to take the Ruby approach in Perl 6, it takes an extra colon to keep the parser happy: @foo.each:{ ... } Ruby gets away without the colon because it require parens around all its arguments except for the magic block, which is required to go outside the parens, if any. That's conducive to the Ruby style at the expense of other styles. But Perl is supposed to be multi-paradigmatic, so I'd rather support many styles, including the ability to pass closures in any argument position, not just the "magic" position. And in particular, I'd also like to be able to drop the parens on things like: if $a eq $b { ... } while $c { ... } for 1,2,3 { ... } So whereas Ruby's syntax actually tends to push you toward .each iterators, Perl 6's syntax will be fairly neutral on the subject, or maybe biased every so slightly away from method iteration by the width of about one character: for @foo { ... } @foo.each:{ ... } But then, a good Ruby programmer would have put a space where there's a colon anyway, so maybe it's a wash. If I wanted to make it even I'd pick something shorter than "each", I suppose. Except "all" is already taken. I suppose there's something to be said for: @foo.for:{ ... } But then you have to think in Japanese, and you'll note that even Matz is too polite to force us gaijin into using postpositions rather than prepositions. On the other hand, maybe I can muster the hubris to speak for all gaijin and say that's okay in this case. :-) Larry