From: Paul Brannan Date: 2008-05-12T23:06:04+09:00 Subject: Re: lambda, ->, haskell, and so on On Sun, May 11, 2008 at 07:24:07PM +0900, Michael Neumann wrote: > Evan Phoenix wrote: > > Not to throw the whole thread into a tizzy again, but why again is: > > > > ->(a,b) { } # stabby proc > > > > better than > > > > def(a,b) { } # anonymous def > > shouldn't that be > > def(a,b) ... end > > otherwise it introduces again a bit of inconsistency. And then "def" is > used for methods, not procs. Despite, I like the syntax :) IMO 'def(a,b) ... end' implies that the code between def..end does not have access to variables in the outer scope (because this is how def works currently). I do like the anonymous def, but not as a replacement for lambda. (it should be faster to call an anonymous def than to call a proc/lambda) Currently we have these kinds of functions: anonymous closure default args checks # args def foo(a,b); end N N Y Y ->(a,b) { } Y Y Y Y lambda { } Y Y N Y proc { } Y Y N N Proc.new { } Y Y N N define_method { } N Y N Y (I can't remember off the top of my head the difference between proc and Proc.new -- are they the same in 1.9?) It would be nice if we could build some consistency into this table so that explaining the differences between all of these was a matter of following rules, rather than memorizing which mechanisms work which way. Paul