From: Charles Oliver Nutter Date: 2008-12-05T06:41:42+09:00 Subject: [ruby-core:20325] Re: Leave my open classes alone (was Behavior: autoload calls rb_require() directly) 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. > > 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. I can appreciate the "choice is good" argument, but I think the Ruby world needs a little less dogmatism about "choice" and "freedom" and "beauty". There's practical concerns here, concerns about API stability, thread-safety, performance, memory efficiency. Too many of those concerns are sacrificed on the altar of "choice" or "freedom". In the case of core classes, we're not talking about closing them down completely; we're talking about guaranteeing to all developers and users that some minimum set of methods will do what you expect them to do, now and forever. We're guaranteeing that 1 + 1 will continue to == 2. And it's not the case where *you* want to override a core method that's the problem...it's the case where someone else overrides it--potentially by mistake--and you don't find out about it until later. Ruby needs to grow up as a language by allowing people who want guarantees to get guarantees. And there's a lot of people who want some minimal, basic guarantees about core classes. - Charlie