Marko Schulz wrote:
> On Fri, Apr 27, 2001 at 11:26:35PM +0900, Yukihiro Matsumoto wrote:
> > Hi,
> > 
> > In message "[ruby-talk:14299] Re: || .. or Question"
> >     on 01/04/27, Marko Schulz <in6x059 / public.uni-hamburg.de> writes:
> > 
> > |> Simply precedence reason.  In Ruby, statements are expressions that
> > |> can't be fit in argument list. 
> > |
> > |Does this mean, that Ruby has an 'list operator' similar to perl with
> > |precedence between '||' and 'or'? Otherwise I still don't understand
> > |how precedence comes in here.
> > 
> > No, no "list operator".  But it's little bit too complicated for me to
> > explain in English (sorry).  Would somebody explain for him?
> 
> I didn't meant that there actually is a list operator. I just cannot
> understand how precedence within an expression determines whether
> something is an expression or not. More conrete it looks odd to me
> that 
>   'puts (n==3 or n==5)' seems to be interpreted as 'puts ((n==3 or) n==5)'
> while
>   'puts (n==3 || n==5)' seems to be interpreted as 'puts ((n==3 || n==5))'


After looking at parse.y:

There's a difference between expressions "expr" and function arguments "arg".
Function arguments are not expressions, but arguments.


expr : expr kOR expr
     .
     | arg


arg  : arg tOROP arg
     .
     .
     | primary
 

So in expressions, both "or" and "||" are handled, whereas in function arguments, 
there is only "||". If you put parenthesis around "n==3 or n==5" then it is handled as
"primary". But the method call itself consumes the first parenthesis after the method name.
A primary can contain an expression surrounded by parenthesis.  
So "puts (n==3 or n==5)" is the same as "puts n==3 or n==5", because the parenthesis 
belong to "puts".
 

Regards

Michael


-- 
Michael Neumann
merlin.zwo InfoDesign GmbH
http://www.merlin-zwo.de