From: daz Date: 2005-08-06T00:51:07+09:00 Subject: Re: new block notation (was: Re: ruby-dev summary 26468-26661) Eric Mahurin wrote: >> --- Jason Foreman wrote: [...] > > A few of us (you, me, Florian) have suggested variants of this: > > { arg-list code } > > You and Florian suggested the delimiter be "->". I suggested > ":"+spacing (to not confuse with symbols) or ;/newline if the > args were made mandatory. > > I think any of these delimiters plus probably others could work > and look good. The general form above is about the most > concise you can get and probably the best if workable. > Nobu has given his assessment to you here: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/150834 > The problem with this is 2 fold: > [...] Yes. The second is the show-stopper: > > 2. If the arg-list/delimiter is optional, it requires an > indeterminate amount of lookahead to determine whether the > lambda/block starts with an arg list or code. A parser > solution to this is to initially treat the arg-list as code and > then if the delimiter is found (could be thought of as an > arg-list operator) in the first statement/expression where that > expression/statement can terminate, treat what is to the left > as the arg-list. I think this should work because as far as I > see any valid arg-list (including defaults) also happens to be > a valid expression. But, after the delimiter is found, the > parse tree for the arg-list would have to be cleaned up and > some extra syntax checking would be needed. Kind of ugly, but > doable. > For the purposes of keeping the discussion relevant, this should be considered impossible, I think. The tight linkage between parser and lexer states means that the subtle differences appearing in either code or argument lists have been occluded. From my (slightly less than) superficial understanding, rolling back the lexer would not be an enjoyable task <>. Maybe possible with a pre-compile pass but that option has been rejected before, I'm sure. Any "desirable" variants should acknowledge that the lexer needs to be able to recognise the arrival of an argument list. - My humble recommendation. daz