|
List Info
Thread: Re: lambda, ->, haskell, and so on
|
|
| Re: lambda, ->, haskell, and so on |

|
2008-05-12 08:39:22 |
|
On Sun, May 11, 2008 at 10:04 PM, Yukihiro Matsumoto < matz ruby-lang.org">matz ruby-lang.org> wrote:
Hi,
In message "Re: lambda, ->, haskell, and so on"
on Mon, 12 May 2008 11:49:12 +0900, Evan Phoenix < evan  fallingsno w.net">evan fallingsnow.net> writes:
|> Personally, I am pretty well satisfied with current ->. In addition,
|> if both Ruby and Perl6 have it (in same syntax), it will soon have
|> large mind share in the dynamic language "market".
|
|Does perl 6 have the -> syntax?
Yes. It39;s the origin. Perl6 is even more radical to change "for"
statement to
for obj -> var {
}
that means a "for" statement to take anonymous function. I once tried
to make block syntax to
method(arg) -> x {
...
}
but felt it was too radical and abandoned.
matz. I read about perl6 closures here: http://dev.perl.org/perl6/doc/design/syn/S04.html
Here are the various forms I find and my understanding:
{ ... } : if the contents is a list, it is interpreted as a hash. Otherwise it is treated as a closure and an optional single argument is passed as $_.
sub { ... } : same except it is always a closure
-> $a, $b { ... } : closure with arguments passed by value.
sub ($a, $b) { ... } : same
<-> $a, $b { ... } : closure with arguments passed by reference (modifying them modifies the original lvalue passed).
The context where I see that the -> syntax is where the value(s) that will be assigned to the params appear before it, so that the -> looks kind of like a reversed assignment and the <-> looks like it does aliasing.
If the -> syntax in ruby can't be used in this context, what's the point? If the perl6 syntax doesn't make sense for ruby, we shouldn9;t be using it.
I still see no reason not to just allow defaults for block arguments ({ |...| ... } or do |...| ... end) and just restrict them to primaries so that there isn't any | ambiguity. Why is anything else needed?
Eric
|
[1]
|
|
|
about | contact Other archives ( Real Estate discussion Medical topics )
|