On Fri, Apr 25, 2003 at 01:07:33AM +0900, dblack / superlink.net wrote:
> Here's an illustration of recent changes, as I understand them....  In
> 1.6.8, the whitespace between the method call and the arglist was
> ignored, but warned about:
> 
>   candle:~$ ruby -vwe 'puts(3).class'
>   ruby 1.6.8 (2002-12-24) [i686-linux]
>   3
>   candle:~$ ruby -vwe 'puts (3).class'
>   ruby 1.6.8 (2002-12-24) [i686-linux]
>   -e:1: warning: puts (...) interpreted as method call
>   3
> 
> but in 1.8.0, the whitespace is taken to mean that you want the
> parenthetical expression to associate to the right:
> 
>   candle:~$ ruby/1.8.0/bin/ruby -vwe 'puts(3).class'
>   ruby 1.8.0 (2003-03-03) [i686-linux]
>   3
>   candle:~$ ruby/1.8.0/bin/ruby -vwe 'puts (3).class'
>   ruby 1.8.0 (2003-03-03) [i686-linux]
>   -e:1: warning: (...) interpreted as grouped expression
>   Fixnum

Thanks for that explanation. FWIW I think it's really a bad idea for
whitespace to play a significant role like that, and I hope that this
decision is reconsidered before 1.8 is released.

I think expressions should parse one way regardless of white space, and if
you want the other way then you do so by adding printing characters:

    puts(3).class  =>  (puts(3)).class    # the default
                   or  puts((3).class)    # the other way

In particular, many people are going to write
    puts( 3 )
or
    puts (3)
purely as stylistic variations, and I think it's a bad idea that you can get
different syntax trees being generated! (Warning or no warning)

Regards,

Brian.