November 26, 2006 Reimplementing interface | ||||
---|---|---|---|---|
| ||||
Bug http://d.puremagic.com/issues/show_bug.cgi?id=502 points out: a class that reimplements an interface, needs also to reimplement all methods from the interface. Currently this means, it is really necessary to do int f( int i ){ return super.f( i ); } I think an alias should do the job. alias SuperClass.f f; comments? |
November 26, 2006 Re: Reimplementing interface | ||||
---|---|---|---|---|
| ||||
Posted in reply to Frank Benoit (keinfarbton) | Frank Benoit (keinfarbton) wrote: > Bug http://d.puremagic.com/issues/show_bug.cgi?id=502 > points out: a class that reimplements an interface, needs also to > reimplement all methods from the interface. > > Currently this means, it is really necessary to do > > int f( int i ){ > return super.f( i ); > } > > I think an alias should do the job. > > alias SuperClass.f f; > > comments? I agree. And I've disputed the excuse for labelling that bug as invalid on this basis. I think the reason for requiring interfaces to be explicitly implemented in that very class is that, if you don't watch out, you may end up implementing the interface by an inherited method with very different semantics. But if you declare it as an alias in the class that implements the interface, then you're showing that you have watched out. And so this should be one way of implementing the interface. I don't really know what practical uses there are for reimplementing the same interface in a derived class, but in any case the same argument for allowing this applies. Stewart. -- -----BEGIN GEEK CODE BLOCK----- Version: 3.1 GCS/M d- s:-@ C++@ a->--- UB@ P+ L E@ W++@ N+++ o K-@ w++@ O? M V? PS- PE- Y? PGP- t- 5? X? R b DI? D G e++++ h-- r-- !y ------END GEEK CODE BLOCK------ My e-mail is valid but not my primary mailbox. Please keep replies on the 'group where everyone may benefit. |
Copyright © 1999-2021 by the D Language Foundation