From: dblack@... Date: 2003-08-20T00:43:05+09:00 Subject: Re: $VERBOSE=true returns warnings from standard library Hi -- On Tue, 19 Aug 2003, Gavin Sinclair wrote: > On Wednesday, August 20, 2003, 12:02:24 AM, Dave wrote: >> > > Could we not make it a rule that stuff in the standard library has to > > meet a basic standard? Rather than disable warning in the library code, > > could we instead fix the warnings? I third this (see Hugh's second :-) > That's a good idea, but in the specific case of "redefine ...", I > think a different approach may be needed. > > Ruby allows you to redefine methods, and the Ruby community encourages > people to take advantage of that. Yes the Ruby interpreter issues a > non-negotiable warning when you do so. Perhaps a warning should *not* > be given (by default) in this case. It could be given when the user > asks for maximum warnings. The original post was about "redefine instance" in singleton.rb, not the classic "method redefined, discarding old xxx" warning. But on the latter subject: > For instance, I consider this good style: > > class Example > attr_accessor :attribute > > # ... > > def attribute=(x) > # something special > end > end > > It lets the reader know up front that they can use #attribute and > #attribute=, and then it changes the implementation, which the casual > reader doesn't need to know - do they? I don't know, but I think the casual reader -- at least, *that* casual -- isn't all that major a player in the game, at least not to the point where attr_accessor's documentation role outweighs its method-defining role, which I think is happening here. It seems that you're defining a method you don't need, solely for the purpose of documenting it, which seems a bit loose. I think the discarding method warning is potentially useful for a case like: class C def x; end def xx; end def xx; end # whoops, meant to type xxx end where you accidentally trample a method. It's a fairly marginal scenario, but it's probably best to have it issue a warning just in case. David -- David Alan Black home: dblack@superlink.net work: blackdav@shu.edu Web: http://pirate.shu.edu/~blackdav