Re: inheritance bug?
Daniel Bonniot <[email protected]>
| Newsgroups | gmane.comp.lang.nice.general |
|---|---|
| Message-ID | <[email protected]> |
>What would be the problem with Dylan like behaviour? > >"define method creates a method and adds it to a generic function in a >module variable. If the module variable indicated is not already >defined, it is defined as with define generic. > >Thus, define method will create a new generic function or extend an old >one, as needed." > > The problem is described in the C# article you linked to. If you later introduce a method with the same name in an imported package, you will suddenly override it silently, while you had no knowledge of that method when you wrote your implementation. So there is absolutely no guarantee that your implementation is meaningful for that method, that it fullfills its contract, ... Similarly, if you rename a "base" method, the overriden one will now silently not override it anymore (that one is OK if you do all renamings with a refactoring tool). One more, if you write the implementation and make a typo in the name or the type, you will not override, and again no get no warning. Basically explicitely overriding (or explicitely declaring a new method) adds some expliciteness and redudancy that allows the compiler to do more checks and make sure you are really doing what you intend to do. One more, huge advantage, is that when you read the code, you immediately see it's a overriding. You get more information, more context to understand the code. Daniel ------------------------------------------------------- SF.Net is sponsored by: Speed Start Your Linux Apps Now. Build and deploy apps & Web services for Linux with a free DVD software kit from IBM. Click Now! http://ads.osdn.com/?ad_id=1356&alloc_id=3438&op=click