From: Eric Mahurin Date: 2005-08-05T00:29:55+09:00 Subject: Re: ruby-dev summary 26468-26661 --- Brian Schr�der wrote: > On 04/08/05, David A. Black wrote: > > Hi -- > > > > On Thu, 4 Aug 2005, [ISO-8859-1] Brian Schr�der 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 That doesn't sound bad and is consistent with "def". But, it does introduce a backwards incompatibility when you have "{ (a) }" in existing code. > or one could use a differnt pair of symbols, though I don't > really like that. > > { a+b } Definitely wouldn't work. Take a look at this: { a+b>2 } Do you interpret it that way or this way: { < a, b=12>a+b > 2 } Here is my proposal: { args : code } Even if when you make the args : optional to preserve compatibility, I think this would be parsable if you treat the arg list (possibly with default expressions) like a normal statment except that the delimiter is ":" instead of ";". This should work because an arg list is a syntactically valid statement. i.e. a=1 other=[3,4] a,b=2,*other When the lexer finds a ":" instead of a ";" or newline as the statement delimiter of first statement, it would treat that as the arg list. I like this because it gives the minimal amount of punctuation for the arg list - one character as a delimiter. ____________________________________________________ Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs