To interface or not to interface

Martin Hinsch hinsch.martin at
Thu May 27 08:26:24 PDT 2010

== Quote from Steven Schveighoffer (schveiguy at's article
> On Tue, 25 May 2010 23:29:34 -0400, Walter Bright
> <newshound1 at> wrote:
> > Steven Schveighoffer wrote:
> >> On Mon, 24 May 2010 18:13:38 -0400, Walter Bright
> >> <newshound1 at> wrote:
> >>
> >>> Steven Schveighoffer wrote:
> >>>> All an interface does is give an abstract representation of functions
> >>>> that are *already there*.  Removing the interface does not remove the
> >>>> functions that implemented the interface.
> >>>
> >>> Then why do interfaces need to be part of the collection component?
> >>> Why can't the user add them if he wants them?
> >>  How do you add an interface to a class?
> >
> > Define an interface who's member functions call the class' member
> > functions.
> Quoting from earlier message:
>    Wrapping seems like it would add more overhead than just implementing
> the interface, especially since D's inliner has some strange restrictions.
> -Steve

I think the main problem is that adding an interface post-hoc on the user's side
is a cumbersome error-prone process. This problem has been avoided quite elegantly
by Go by the way, which allows interfaces to be "applied" to all types that
conform without requiring inheritance (can't resist to mention that I proposed
this exact approach some years ago (long before Go was released) in this news
group ;-) ).


More information about the Digitalmars-d mailing list