J
Jim Freeze
* Casper said:To be honest, that the following two lines
puts (3+4).abs
puts(3+4).abs
are semantically different *feels* very broken to me. My gut says that
this is a vector for confusion and the introduction of bugs.
I think it depends on what binding you prefer most.
Consider
method_that_returns_some_string(arg).upcase!
I think this does what one would expect. It is going
to upcase the returned string.
But, if it is written with a space after the method name
method_that_returns_some_string (arg).upcase!
you suggest that this should bind the same as if the space
were not present. That means that constructs like
sqrt (-2).abs
could not be written without an extra set of ()'s.
Doesn't this rule that ()'s after a method
are always bound to the method imply that ()'s
are essentially always needed, especially if
any argument uses parens?
sqrt ( (-2).abs )
This clearly needs the outer parens.
method_take_two_args arg1, (arg2+arg3)
While this may be valid.
method_take_two_args (arg1+arg2), arg3
But, this would not work and would need to be written as:
method_take_two_args ((arg1+arg2), arg3)
or
method_take_two_args (arg1+arg2, arg3)
Ugh. The more I look into this, the more I like the elegance
of Ruby.