On Fri, Dec 05, 2008 at 06:25:08AM +0900, Dave Thomas wrote:
> Please, no.
>
> Every time we do something like this, we add more special cases to the  
> language. Right now, classes are open. We allow people to modify their  
> behavior. That's just Ruby. Take away plus, and you limit my freedom.  
> What's next? Maybe Fixnum.to_s. And then maybe Struct.to_s. And then  
> maybe all internal classes get closed, and no one would be able to  
> create things such as Symbol.to_proc.

Is there a use case where redefining Fixnum#+ actually solves a
real-world problem?

There are other operations in Ruby that we can't override (logical and
and logical or, for example).  While this means Ruby is less flexible
than it could be, the missing flexibility does not mean missing
usability or expressiveness.

> I'd much rather see change going the other way. I'd like to see a =  
> "cat" calling String.new. I'd like to see fewer special cases.

Something like this was tried with arrays in the 1.7 series, but
performance was significantly degraded relative to 1.6.  Maybe now that
we have a faster VM we could do this (and avoid the method dispatch
using the same trick as for Fixnum#+).  IIRC though it also caused other
problems (it was difficult to override Array.allocate correctly, without
causing an infinite loop, because it could easily be called implicitly).

> If require is broken, then fix it. But don't stop me replacing it if I  
> want. And if I replace it incorrectly (making it not thread safe, for  
> instance) that then becomes my fault.

Did someone suggest this?  If so I missed it.

> Ruby is about choice. If I wanted a language implementor to tell me what 
> I can change and what I can't change, I'd use Python or Java.

Ruby is also about expressiveness and readability.  Often having too
many choices affects culture in undesirable ways.  Perl's motto of
"there's more than one way to do it" actually decreases readability
rather than improving it.

I'm all for choice, but not without weighing the consequences.  In the
particular case of Fixnum#+, I feel the cost outweighs the benefit.

Paul