C#'s greatest mistakes

Jonathan M Davis jmdavisProg at gmx.com
Sat Nov 27 20:04:00 PST 2010


On Saturday 27 November 2010 19:40:09 Michel Fortin wrote:
> On 2010-11-27 20:55:51 -0500, Adam Burton <adz21c at gmail.com> said:
> > Personally I think having an "implements" makes sense (that loops through
> > the methods of an interface and checks the type has matching methods, not
> > the same as having a class "implement" an interface which is more like
> > inheritance). However as you say, that is not how interfaces in their
> > current form are designed to be used so I understand why people disagree.
> 
> Well, if you consider the previously discussed 'adaptTo' function
> template, all types can be adapted to an interface (via a
> template-generated wrapper class). So "implements" for structs isn't
> too far off, as you can use the struct to implement the interface via
> 'adaptTo'.

Except that

1, adaptTo!() is going to wrapping the struct in a class, so it's technically 
the class which implements the interface (even if it's just a wrapper).

2. More importantly, now you have the added confusion of is it a class, a 
struct, or a struct wrapped by a class that you're dealing with? So, talking 
about implements can quickly become confusing.

It quickly starts looking like we need new terms which are more precise if we 
want to have clear conversations on the matter.

- Jonathan M Davis


More information about the Digitalmars-d mailing list