--- nobuyoshi nakada <nobuyoshi.nakada / ge.com> wrote: > Hi, > > At Thu, 13 Oct 2005 14:33:08 +0900, > Caleb Clausen wrote in [ruby-talk:160349]: > > A little reflection should have shown me the futility.... > Presumably > > Matz and Nobu have tried all this already and been > frustrated by the > > same obstacle that I had been beating my brain bloody > against. Why > > should I, with my pathetic and measly yacc skills, expect > to do any > > better? > > Me? I'd tried it once by differentiating goal-post from > bit-or in the lexer. > > http://www.rubyist.net/~nobu/t/20050805.html#p01 > > I don't remember the detail too, however the essential idea > seems to be adopted partly. Anybody ever just consider making a new expression (or maybe RHS?) rule just for these default values such that "|" was not in this expression? (...) in this or-less expression would still use the normal expression. Wouldn't this solve the problem? You'd just be forced to use (...) whenever you wanted to "|". That doesn't seem so bad. ... { |a,b=1|2|a*b } # b default: 1, code: 2|a*b ... { |a,b=(1|2)|a*b } # b default: (1|2), code: a*b ... { |a,b=1+2|a*b } # b default: 1+2, code: a*b I don't see any ambiguity doing it this way. Of course the other reason for the new syntax is a shortented lambda syntax. I'd say just to do what was being done previously in 1.9: use {} and resolve ambiguities with {} hash. The simple solution to resolve ambiguities is in this lambda, require ||. If you didn't want the ||, you would have to use the equivalent: {|*| ... }. When the parser encounters a "{", you only have to lookahead one token to see whether it is a lambda (next token: "|") or a hash (next token: not a "|"). Another option for a shortened lambda is to put some symbol (that doesn't make sense in front of a hash) in front of a block to make it a lambda. A few options for that would be: &{ }, \{ }, .{ }, ^{ }. You may even be able to treat some of these as simply another Kernel method (alias for lambda). __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com