On Fri, Apr 25, 2003 at 11:30:25PM +0900, Chris Pine wrote:
> Or make poetry mode illegal.  (Not a great option, but I had to throw it in
> for completeness.)

That means: all method calls must have parentheses around their arguments.

Perhaps it would be OK for method calls with no arguments to omit the '()'.
I've not thought to deeply about the consequences. It would mean that

    foo - bar    would be interpreted as foo() - bar(), not foo(-bar())

which seems reasonable. But you would lose the ability to write

    puts "hello"

> ----------------------------
> The latter would make the language less C-like, and would force you to write
> 
>     (sin a) + b
> 
> instead of
> 
>     sin(a) + b
> 
> What do people think of that??
> 
> ----------------------------
> 
> That is really cool!  But I think ruby is too old for such a change.
> Anyway, what would this code do?
> 
>   sin a + b . abs

Everything after the 'sin' would be its argument, so it would be equivalent
to

    sin( a + (b.abs) )

given that '.' binds more tightly than '+'. In this case, Ruby behaves like
this already, and both ruby-1.6.8 and 1.8.0p2 are the same.

It is when you add parentheses to *parts* of the expression that ambiguities
arise.

1.6.8:

    sin (a+b).abs   \ =>  both are treated as (sin( a+b )).abs
    sin(a+b).abs    /

(i.e. the opening parenthesis is always treated as grouping the argument
list of 'sin')

1.8.0p2:

    sin (a+b).abs     =>  sin( (a+b).abs )
    sin(a+b).abs      =>  (sin( a+b )).abs

That's a big difference for one space to make.

> It seems such things should be clear.  Without adding parens *everywhere*
> (and becoming Lisp), I don't see how it would be easy to understand what the
> above does.  (Of course, I wouldn't know what the above does in Ruby 1.6 or
> 1.8, either, without trying it in irb first; is it good that we have irb for
> such things, or is it bad that I need it for such things?)

I think the 1.6.8 rule is easy to understand:

* if a method call is followed by an opening parenthesis, everything from
  this parenthesis to the closing one is the argument list for the method

  so:    sin (a+b) + c
         ^^^ ^^^^^
        meth  arg

That's it. It will catch you out if you write

        puts (a+b).abs

instead of

        puts ((a+b).abs)

> Perhaps people would get used to it if there wasn't already so much ruby
> code with the parens like they are now... but, like I said, I think Ruby is
> too old for such a change.

You are probably right. But the same argument could be used against 1.8.0p2

Regards,

Brian.