From: Ragav Satish Date: 2008-10-04T12:54:48+09:00 Subject: Re: No warning for redefine Daniel DeLorme wrote: > David A. Black wrote: >> >> On Fri, 3 Oct 2008, Han Holl wrote: >>> >>> Shouldn't the following: > [snip] >>> produce something like: >>> >>> demo.rb:9: warning: method redefined; discarding old function >>> >>> Behaviour now is to discard the mixed-in method silently. >> >> It's not discarded; it's still there (in the module) and you can use >> it with other classes, or reach it through 'super' in the override. > > But since the override doesn't use super, in effect it has the same > effect as discarding the included 'function', at least as far as the > main object is concerned. I wish ruby would output a warning for cases > like this, i.e. "warning: method `foo' ignores method defined in > /path/to/file.rb:123" The behavior is unsurprising if you think of inheritance when you see Module inclusion. If on the other hand if your mental model is "copying methods" from the Module into the target then I can see the confusion. You don't expect warnings when a derived class overrides a base class method now do you? --Ragav -- Posted via http://www.ruby-forum.com/.