From: Bob Hutchison Date: 2005-09-27T13:16:09+09:00 Subject: Re: Is there an issue with a library extending Object? On Sep 26, 2005, at 6:45 PM, Ara.T.Howard wrote: > On Tue, 27 Sep 2005, Bob Hutchison wrote: > >> I am writing a library for Ruby programmers. What are the issues >> with adding >> methods to the Object class? I'm not talking about the >> practicalities of it >> -- those are as easy as could be and work. What I am concerned >> with is the >> reaction a programmer using that library might have. The benefit is a >> simplification of a particularly error-prone, tedious, ugly, and >> repetitive >> test in the library user's code (that might not show up in unit >> tests). I >> don't know what the disadvantages might be, name conflict I >> suppose. Any >> others? Any guidelines as to when extending standard classes is >> considered >> okay, or not? Is there an expectation in the Ruby culture? is this >> kind of >> thing considered rude, or worse? >> > > is there any reason you can't extend the bjectinstead of classes? > Good suggestion. I gave this a shot. It works for the key bits and pieces *except* for symbols. So, at the moment, I have a configuration option that will determine whether to extend Symbol (only), or will convert symbols to strings. As I play with it, this is beginning to look like an expensive proposition. Any idea what the overhead to extending an instance with a module is? I think I'm going to have to re-think this. Thanks for the help. Cheers, Bob ---- Bob Hutchison -- blogs at Recursive Design Inc. -- Raconteur --