On Wednesday, August 20, 2003, 12:02:24 AM, Dave wrote:


> On Tuesday, August 19, 2003, at 03:21 AM, Yukihiro Matsumoto wrote:

>> |c:/ruby180/lib/ruby/1.8/singleton.rb:98: warning: redefine instance
>> |
>> |Wouldn't it be nice if there was an option to turn off warnings for
>> |modules in the standard distribution?
>>
>> Indeed.  I will fix.
>>

> 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?

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.

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?

Running this code:
 -w    warns that attribute= is redefined
 -W0   doesn't
 -W1   doesn't
 -W2   does (this is equivalent to -w)

The problem we have is that people commonly run with -w in order to
get real warnings.  People don't want to get bombarded with the above
kind of warning at this level, do they?

Cheers,
Gavin