On 04/08/05, David A. Black <dblack / wobblini.net> wrote: > Hi -- > > On Thu, 4 Aug 2005, [ISO-8859-1] Brian Schröäer wrote: > > > On 04/08/05, David A. Black <dblack / wobblini.net> wrote: > >> Hi -- > >> > >> On Thu, 4 Aug 2005, [ISO-8859-1] Brian Schröäer wrote: > >> > >>> [snip] > >>> > >>> Then why don't we use two different delimiters, e.g. (,) which would > >>> even unify with method declaration. > >>> > >>> { (a, b=12) a+b } > >>> is quite clear, and counting nesting parenthesis has to be done in any > >>> parser so this > >>> > >>> { (a=12, (b,c) = [1,2]) a+b**c } > >>> is also possible > >> > >> However, { (a) } would be ambiguous. (I don't particularly mind living > >> without default values in blocks, but I think () wouldn't fly.) > > > > One could disambiguate this the same way it is done with methods: > > > > { () (a) } > > > > like in > > > > def anonymus() (a) end > > But then you'd have empty parens all over the place. I guess there > aren't that many paramless blocks, but there are some, like: > > Hash.new { () [] } # ugh > Why should you write it like that. If there is no starting ( there is no argument list. So Hash.new { [] } would work in this case. You'd only need an () if the expression starts with a (. But maybe there are better options. regards, Brian > > or one could use a differnt pair of symbols, though I don't really like that. > > > > { <a, b=12> a+b } > > irb(main):005:0> def x(a = 1 > 0); p a; end > => nil > irb(main):006:0> x > true > Ahh, I didn't think of that, and I'm shure theres also a big flaw in my other thoughts. regards, Brian -- http://ruby.brian-schroeder.de/ Stringed instrument chords: http://chordlist.brian-schroeder.de/