From: Dave Thomas Date: 2008-12-05T06:25:08+09:00 Subject: [ruby-core:20323] Leave my open classes alone (was Behavior: autoload calls rb_require() directly) On Dec 4, 2008, at 1:38 PM, Paul Brannan wrote: > On Fri, Dec 05, 2008 at 03:25:42AM +0900, Charles Oliver Nutter wrote: >> I agree. There's no practical reason anyone should be able to >> override >> Fixnum#+, after all, and protecting the core simplifies >> implementation >> and optimization too. > > I agree. Not having to check to see if Fixnum#+ is redefined each > time > we want to add two integers would be a noticeable performance > improvement. 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. 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. 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. 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. Dave