From: Michal Suchanek Date: 2008-05-22T21:21:46+09:00 Subject: Re: lambda, ->, haskell, and so on On 19/05/2008, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: lambda, ->, haskell, and so on" > > on Tue, 20 May 2008 01:49:04 +0900, Nate_Wiger@playstation.sony.com writes: > > |First off, it already means something specific in well-established > |languages such as Perl5 and C/C++. On my team, I have C++ coders that dip > |into Ruby (and vice-versa), and I really don't want to deal with "->" > |confusion. Most other pieces of syntax are easy to overcome, but "->" is > |nearly as pervasive as "+". > > > Point taken, although I am very optimistic about the human ability to > adopt languages. If one can handle both Spanish and English at the > same time (or even worse, Japanese and English for my case), I can > believe he can handle '->' without confusion, if it's prefix form > unlike C++. ;-) > > > |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 could be a chance for the keyword like "fun" or "fn", but > there's little hope. > I would be in favor of a short keyword. None of the glyphs proposed so far represent the concept well and all are pretty hard to type. The exception is /\ which has both parts quite near to each other and neither requires shift to type. However, that one is quite ambiguous for the parser. Perhaps something like ,\ or .\ would be better in that regard but still anything with a backslash in it is probably quite fishy. I really dislike operators like -> or => where one part requires shift to type and the other does not. And don't start about non-English keyboards - I have to switch to US layout to type all the programming punctuation. There is probably no other layout that has it all. Thanks Michal