|
List Info
Thread: Re: lambda, ->, haskell, and so on
|
|
| Re: lambda, ->, haskell, and so on |
  United States |
2008-05-21 13:53:18 |
|
Hi-
Yukihiro Matsumoto <matz ruby-lang.org>
wrote on 05/19/2008 10:23:29 AM:
> Hi,
>
> In message "Re: lambda, ->, haskell, and so on"
> on Tue, 20 May 2008 01:49:04 +0900, Nate_Wiger playstation.sony.
> com writes:
>
> |Second, there are a couple alternatives that we could use, leveraging
> |existing Ruby syntax:
> |
> | http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/16662
> | http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/16616
>
> So, you prefer lambda(x) {...} or x => {...} over ->(x){...},
right?
> The latter (=>) conflicts with other part of Ruby syntax, namely
hash
> literals, besides it complicates the language.
>
> I am not fond of "lambda" being keyword, because
>
> * it changes meaning of the valid syntax ("lambda(a){p
a}" is valid
> in 1.8 with different semantics).
> * it's long (6 letters). considering the functional programming
> trend in Ruby and other languages, we will see anonymous
function
> expression more often in the future.
There is also Ara's suggestion of using "def"
for this purpose:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/16804
This would make Ruby more consistent with other languages:
Ruby
def name; "stuff";
end
name = def() "stuff";
end
Perl 5
sub name { "stuff";
}
$name = sub { "stuff";
}
JavaScript
function name(){ "stuff";
}
name = function(){ "stuff";
}
(Perl 6 is not really worth considering, since there's
not much evidence
it will actually ship.)
> There could be a chance for the keyword like
"fun" or "fn", but
> there's little hope.
Hopefully a solution can be found that the core team
is happy with. Personally,
I have seen many people in opposition to the use of
"->" to mean lambda in
this context. I think a better alternative can
be found.
Thanks for your consideration.
Nate Wiger
PlayStation
|
| Re: lambda, ->, haskell, and so on |
  United States |
2008-05-21 17:16:23 |
|
Hello,
Maybe there is the case that the def
is being squeezed into being more meaningful for function definition than
general definition. You have very good reasoning for consistency. Other people
have good ideas for layout of code and if they come together would possibly
work well. An example:
nameOfFunc = func (a, b) { a + b; }
def nameOfFunc; func(a, b) { a + b; }; end
def nameOfFunc(a, b); func { a + b; }; end
Oh, and while typing these, func felt more
natural to my fingers than just fun. I think though that the f and n are the
most important to include and fun or fnc or other choices add mostly only
flare, favor, or resistance to settling the choice. Good day.
Yemi Bedu
P&R Fasteners
325 Pierce St
Somerset, NJ
08873
732-302-3600
From:
Nate_Wiger playstation.sony.com [mailto:Nate_Wiger playstation.sony.com]
Sent: Wednesday, May 21, 2008 2:53
PM
To: ruby-core ruby-lang.org
Subject: Re: lambda, ->,
haskell, and so on
Hi-
Yukihiro
Matsumoto <matz ruby-lang.org> wrote on 05/19/2008 10:23:29 AM:
> Hi,
>
> In message "Re: lambda, ->, haskell,
and so on"
> on Tue, 20 May 2008 01:49:04
+0900, Nate_Wiger playstation.sony.
> com writes:
>
> |Second, there are a couple alternatives that
we could use, leveraging
> |existing Ruby syntax:
> |
> |
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/16662
> |
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/16616
>
> So, you prefer lambda(x) {...} or x =>
{...} over ->(x){...}, right?
> The latter (=>) conflicts with other part
of Ruby syntax, namely hash
> literals, besides it complicates the
language.
>
> I am not fond of "lambda" being
keyword, because
>
> * it changes meaning of the valid
syntax ("lambda(a){p a}" is valid
> in 1.8 with different
semantics).
> * it's long (6 letters).
considering the functional programming
> trend in Ruby and other
languages, we will see anonymous function
> expression more often in the
future.
There is
also Ara's suggestion of using "def" for this purpose:
http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/16804
This would
make Ruby more consistent with other languages:
Ruby
def name; "stuff"; end
name = def() "stuff"; end
Perl 5
sub name { "stuff"; }
$name = sub { "stuff"; }
JavaScript
function name(){ "stuff"; }
name = function(){ "stuff"; }
(Perl 6 is
not really worth considering, since there's not much evidence
it will
actually ship.)
> There
could be a chance for the keyword like "fun" or "fn", but
> there's little hope.
Hopefully a
solution can be found that the core team is happy with. Personally,
I have seen
many people in opposition to the use of "->" to mean lambda in
this
context. I think a better alternative can be found.
Thanks for
your consideration.
Nate Wiger
PlayStation
|
| Re: lambda, ->, haskell, and so on |
  United States |
2008-05-22 04:55:23 |
Hi --
On Thu, 22 May 2008, Nate_Wiger playstation.sony.com
wrote:
> Hi-
>
> Yukihiro Matsumoto <matz ruby-lang.org> wrote on
05/19/2008 10:23:29 AM:
>> Hi,
>>
>> In message "Re: lambda, ->, haskell, and so
on"
>> on Tue, 20 May 2008 01:49:04 +0900,
Nate_Wiger playstation.sony.
>> com writes:
>>
>> |Second, there are a couple alternatives that we
could use, leveraging
>> |existing Ruby syntax:
>> |
>> | http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ru
by/ruby-core/16662
>> | http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ru
by/ruby-core/16616
>>
>> So, you prefer lambda(x) {...} or x => {...}
over ->(x){...}, right?
>> The latter (=>) conflicts with other part of
Ruby syntax, namely hash
>> literals, besides it complicates the language.
>>
>> I am not fond of "lambda" being keyword,
because
>>
>> * it changes meaning of the valid syntax
("lambda(a){p a}" is valid
>> in 1.8 with different semantics).
>> * it's long (6 letters). considering the
functional programming
>> trend in Ruby and other languages, we will see
anonymous function
>> expression more often in the future.
>
> There is also Ara's suggestion of using "def"
for this purpose:
>
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ru
by/ruby-core/16804
I think it was originally Dave Thomas's idea (at RubyConf
2005). I'm
also in favor of it, but see Matz's comments earlier in the
thread
about concerns over the connotations of "def[ine]"
with regard to
anonymity.
> This would make Ruby more consistent with other
languages:
>
> Ruby
> def name; "stuff"; end
> name = def() "stuff"; end
>
> Perl 5
> sub name { "stuff"; }
> $name = sub { "stuff"; }
>
> JavaScript
> function name(){ "stuff"; }
> name = function(){ "stuff"; }
I wouldn't worry about that as a goal in itself (I love Ruby
largely
for the ways in which it is *not* consistent with other
languages
but it's interesting to be reminded of these. Again, see
Matz's
comments about "def".
David
--
Rails training from David A. Black and Ruby Power and
Light:
INTRO TO RAILS June 9-12 Berlin
ADVANCING WITH RAILS June 16-19 Berlin
INTRO TO RAILS June 24-27 bond (Skills
Matter)
See http://www.rubypal.com for
details and updates!
|
|
[1-3]
|
|