From: Eric Mahurin Date: 2008-05-12T22:39:22+09:00 Subject: Re: lambda, ->, haskell, and so on ------=_Part_5303_6552010.1210599561399 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Sun, May 11, 2008 at 10:04 PM, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: lambda, ->, haskell, and so on" > on Mon, 12 May 2008 11:49:12 +0900, Evan Phoenix > 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. It'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 shouldn'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 ------=_Part_5303_6552010.1210599561399 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Sun, May 11, 2008 at 10:04 PM, Yukihiro Matsumoto <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@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.  It'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 shouldn'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

------=_Part_5303_6552010.1210599561399--