From: Trans Date: 2005-08-05T02:16:06+09:00 Subject: Re: ruby-dev summary 26468-26661 Yukihiro Matsumoto wrote: > Hi, > > In message "Re: ruby-dev summary 26468-26661" > on Thu, 4 Aug 2005 22:38:06 +0900, "David A. Black" writes: > > |> I like it! Looks much more uniform and consistent with function > |> syntax than {|...| ...} > | > |I assume you mean method syntax. But why is that important? Until > |this new syntax was posted, I'd never heard anyone complain that they > |found it hard to recognize {|...| } as a code block. Now there seems > |to be a retroactive sentiment in the air that the block syntax is, and > |always has been, obscure or garbled. > > lambda is an anonymous function, so that it requires full syntax of > function/method argument, including optional arguments, keyword > arguments, block arguments etc., not just parallel assignment as in > plain block parameters. > > |If uniformity is important maybe def should be redesigned: > | > | def x |a,b,c=1| > | end > > Stop joking. ;-) > Unlike others, I have never given uniformity a top priority. If lambda === Method (minus context), I don't think he would be joking. def x |a,&b| b[a] end x(1) def |a| a+1 end But that does nothing to solve | ambiguity. So forget 'em and go back to parens: def x(a,&b) b[a] end x(1) def n(a,b) a+1 end Such that #def returns a lambda/Method. The name of the lambda, n, would be local to the block, and while usually extraneous, it can be useful as a reference to the block itself. [:a,:b,:c].each def n(i) p n.count; end #=> 1 2 3 That still leaves { } notation. If { == def and } == end, as D. Black "jests", at first it seems ambiguous. But actually I don't think it is. x(1) { n(a,b) a+1 } is decernable from: x(1) { n(a,b) ; a+1 } for example. Yet I agree, over unifority can be hard on the eyes. Which is why #do makes a good substitute for #def in block contexts. T.