From: Yehuda Katz Date: 2009-08-24T14:15:08+09:00 Subject: [ruby-core:25076] Re: Proposal: Simpler block format --00c09f905f9109fb240471dc4dbd Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit To say it another way, I think it's simplifying to the programmer to be able to explain: "return goes up to the nearest def" -- Yehuda On Sun, Aug 23, 2009 at 9:37 PM, Yehuda Katz wrote: > 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 > -- Yehuda Katz Developer | Engine Yard (ph) 718.877.1325 --00c09f905f9109fb240471dc4dbd Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable To say it another way, I think it's simplifying to the programmer to be= able to explain:

"return goes up to the nearest de= f"

-- Yehuda

On Sun, Aug 23, 2009 at 9:37 PM, Yehuda Katz <wycats@gmail.com> wrote:
I think the proposal is:

def { somethi= ng }

or

def do
= =A0=A0something
end

which would declare = a lambda. I think differences between lambda and method are quite small--sm= all enough to justify collapsing ideas in the mind of the programmer. Here = are similarities:
  • 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 Ma= tsumoto <matz@ruby-lang.org> wrote:
Hi,<= br>
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 <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
Developer | Engine Yard
(ph) 718.877.1325



--
Yehuda Katz
Develope= r | Engine Yard
(ph) 718.877.1325
--00c09f905f9109fb240471dc4dbd--