From: Robert Klemme Date: 2011-10-11T23:50:06+09:00 Subject: Re: why does `a + f b` not parse? On Tue, Oct 11, 2011 at 4:33 PM, Phillip Gawlowski wrote: > Don't top post, please. > > 2011/10/11 Bartosz Dziewoński : >> Yes, I think we all know that; the question is, why does 2 + sqrt(5) >> parse, but 2 + sqrt 5 does not? I've been wondering this myself - is >> that syntax somehow ambiguous? > > So, which one shall it be? > >  2.+.sqrt(5) >  2.+(sqrt(5)) >  2.+.sqrt.5 >  2.+(sqrt.5) >  2.+(sqrt(5)) I believe the versions which turn a space into a dot are not valid candidates. Or is there any place other than for operators where this happens in Ruby? I mean "a b" can never by "a.b" but must always be "a(b)". That leaves only "2.+(sqrt(5))" on your list (item 2, same as item 5). It's the same with ordinary methods: $ ruby19 -ce '1 + f 2' -e:1: syntax error, unexpected tINTEGER, expecting keyword_do or '{' or '(' $ ruby19 -ce 'a.b c, d e' -e:1: syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '(' $ ruby19 -ce 'a.b c, d(e)' Syntax OK $ ruby19 -ce 'a b, c d' -e:1: syntax error, unexpected tIDENTIFIER, expecting keyword_do or '{' or '(' $ ruby19 -ce 'a b, c(d)' Syntax OK 16:48:16 oz-56838-negative-session-count$ ruby19 -ce 'a.b c, d do end' Syntax OK I think as soon as the comma is missing the end of the argument list or a nested argument list is expected by the parser (which is also indicated by the error message). Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/