-> a b << ... >>
where C<< -> >> is a literal right arrow char and C<<< << >>> and C<<< >>
>>> are literal guillemets (delimiting blocks). Just wonder wether by any
chance *that* language has had any influence on the
-> $x, $y { ... }
construct.
Michele
--
>> Di solito vedo persone come te svenute nelle taverne.
> Ancor PRIMA che ti sentano l'alito?
Non accettero' la tua impertinenza restando seduto!
- "don't t0uch" su it.discussioni.litigi
Nope. I used to think RPN was completely unnatural. Then I started
learning Japanese, and now I not so sure am. :-)
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.
Larry
> 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?
Regards,
David
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
> 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:{ ... }
act any are ask cog cue did ere for get got has hop jet job kin
let map mix net now one ore per pro put run set tag
I won't describe why I think each one would be appropriate, since if
it's not obvious, it's a bad choice ;-)
I find myself wondering if this is going to allow people to write
smalltalk style method selectors...
@foo.inject:0 into: -> $accum, $each { $accum + $each }