From: Michel Martens Date: 2005-08-10T23:00:05+09:00 Subject: Re: new block notation (was: Re: ruby-dev summary 26468-26661) On 8/8/05, Yukihiro Matsumoto wrote: > Hi, > > In message "Re: new block notation (was: Re: ruby-dev summary 26468-26661)" > on Sun, 7 Aug 2005 02:53:06 +0900, Florian Gro� writes: > > |Should be okay as long as it isn't used as a method name. The 1.9 () on > |local variables change was undone after all, right? > > Right. But adding a new reserved word makes all programs using that > word as a local variable invalid. The concern about backwards compatibility shouldn't be such, and instead we should focus on what looks / works best. I think blocks, lambdas, procs and methods should look alike and behave alike. All of them hold the same kind of abstraction and the differences described in this thread can be inferred by context. The idea behind all of them is as follows: -For methods, blocks, lambdas and procs with parameters: "Take some objects and do some tasks." -For methods, blocks, lambdas and procs without parameters: "Do some tasks." An approximation would look like this: take a, b do puts a, b end do puts "Hi!" end some_object.meth take a, b do transform a, b end It's my opinion that deciding on this linguistic structure is more important than the symbols and keywords to be used, because it's at this point that the mental process is reflected. I can offer some alternatives that keep the structure unaltered: -With parameters: some_object.meth -> a, b { transform a, b } some_object.meth get a, b do transform a, b end some_object.meth for a, b do transform a, b end -Without parameters: meth = do puts "Hi!" end meth = { puts "Hi!" } Below are more examples with the hypothetical keyword 'get'. The current keyword 'for' can also be considered, but I think 'take' or 'given' is the concept to be explained. # Lambda definition without parameters, do ... end: do puts "Hi!" end # Lambda definition without parameters, { ... }: { puts "Hi!" } # Lambda definition with parameters, do ... end: get a, b do puts a, b end # Lambda definition with parameters, { ... }: get a, b { puts a, b } # Block definition without parameters, do ... end: something.meth do puts "Hi!" end # Block definition without parameters, { ... }: something.meth { puts "Hi!" } # Block definition with parameters, do ... end: something.meth get a, b do puts a, b end # Block definition with parameters, { ... }: something.meth get a, b { puts a, b } # Side note: hash syntax ["key" : "value"] # Side note: empty hash syntax [:] > > matz. > >