The Non-Virtual Interface idiom in D
Steven Schveighoffer
schveiguy at yahoo.com
Sun Sep 27 14:52:23 PDT 2009
On Fri, 25 Sep 2009 16:49:27 -0400, Andrei Alexandrescu
<SeeWebsiteForEmail at erdani.org> wrote:
> This leads to the interesting setup in which an interface should ideally
> define some signatures of to-be-defined functions, but disallow client
> code from calling them. For the clients, the same interface should
> expose some higher-level final functions.
There are also some other benefits to allowing defining interface
implementation, such as defining one function in terms of another (public)
function. For example, take a look at:
http://www.dsource.org/projects/dcollections/docs/current/dcollections.model.Collection.html
Look at the definition for both remove functions, the one which takes no
bool can easily be defined in terms of the one that takes a bool reference
(in fact, this is what I do in all the implementations).
The only issue is that you run into multiple inheritance issues (as
brought up by Yigal)...
vote++
-Steve
More information about the Digitalmars-d
mailing list