From: Yehuda Katz Date: 2009-08-24T13:37:24+09:00 Subject: [ruby-core:25073] Re: Proposal: Simpler block format --001485ecd28cecf4c90471dbc582 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit I think the proposal is: def { something } or def do something end which would declare a lambda. I think differences between lambda and method are quite small--small enough to justify collapsing ideas in the mind of the programmer. Here are similarities: - Declared arguments are mandatory - return inside "method" returns from method, not the lexically enclosing block - yield inside "method" yields to block passed into method, not the lexically enclosing block Differences: - Method has "self" belonging to its object -- lambda inherits self from its lexical scope. However, this just means that lambdas are methods bound to the current scope. In constrast, procs are different: - Declared arguments are optional - return inside proc or block returns from the lexically enclosing block - yield inside proc of block yields to block passed into lexically enclosing block In essence, we have two different constructs here, with four different ways to describe them (method, lambda, proc, block). All I am suggesting is that we collapse down the four ways to describe into the two actual constructs :) -- Yehuda On Sun, Aug 23, 2009 at 9:21 PM, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: [ruby-core:25068] Re: Proposal: Simpler block format" > on Mon, 24 Aug 2009 13:03:53 +0900, brian ford > writes: > > |Could we add def {} and see by usage which prevails? Or take a > |world-wide vote (perhaps weighted by number of lines of Ruby code > |written by the voter)? > > The def keyword is to define a method. I assume your def {} proposal > is to declare an anonymous procedure object, which is NOT a method at > all. For me, the difference is big enough to reject the proposal. > > matz. > > -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 --001485ecd28cecf4c90471dbc582 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable I think the proposal is:

def { something }
or

def do
=A0=A0something
end

which would declare a lambda. I think = differences between lambda and method are quite small--small enough to just= ify collapsing ideas in the mind of the programmer. Here are similarities:<= /div>
  • Declared arguments are mandatory
  • return inside "m= ethod" returns from method, not the lexically enclosing block
  • = yield inside "method" yields to block passed into method, not the= lexically enclosing block
Differences:
  • Method has "self" belong= ing to its object -- lambda inherits self from its lexical scope.
=
However, this just means that lambdas are methods bound to the current= scope.

In constrast, procs are different:
  • De= clared arguments are optional
  • return inside proc or block returns f= rom the lexically enclosing block
  • yield inside proc of block yields= to block passed into lexically enclosing block
In essence, we have two different constructs he= re, with four different ways to describe them (method, lambda, proc, block)= . All I am suggesting is that we collapse down the four ways to describe in= to the two actual constructs :)

-- Yehuda

On Sun, Aug 23, 2009 at 9:21 PM, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:
Hi,

In message "Re: [ruby-core:25068] Re: Proposal: Simpler block format&q= uot;
=A0 =A0on Mon, 24 Aug 2009 13:03:53 +0900, brian ford &l= t;brixen@gmail.com> writes:

|Could we add def {} and see by usage which prevails? Or take a
|world-wide vote (perhaps weighted by number of lines of Ruby code
|written by the voter)?

The def keyword is to define a method. =A0I assume your def {} propos= al
is to declare an anonymous procedure object, which is NOT a method at
all. =A0For me, the difference is big enough to reject the proposal.

=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0matz.




--
Yehuda Katz
Develope= r | Engine Yard
(ph) 718.877.1325
--001485ecd28cecf4c90471dbc582--