why can't structs implement interfaces?

Don nospam at nospam.com
Wed Nov 25 01:30:40 PST 2009


bearophile wrote:
> Bill Baxter:
> 
>> The good thing is that since most of the machinery is there, the
>> actual compiler changes required would mostly be just rewrites of new
>> syntax in terms of existing functionality.
> 
> I agree, this looks like something that can be added to D even after D2 comes out of alpha.
> But Andrei warns us that here it's easy to overdo the design. So I think that keeping usability low (= keeping things handmade and low-tech) can be better than a Byzantine and limited design.
> 
> 
>> In particular there's not a good way for the compiler to give good
>> error messages about why a concept is not satisfied by a particular
>> type.
> 
> Time ago I have asked for a "small" compiler feature: when a function/class template creates a compile-time error (because some of the code inside it is not compatible with the specific type given to the template) I'd like the D compiler to act as GCC, telling me not just where there is the error inside the template, but also and *before* that error message to show me the line of where the template is instantiated. This is another small feature that can be added after D2 "finalization".

That's been requested many times. I posted a patch to Walter to do 
exactly that. It was beautiful. It detected recursive template 
expansions, and gave really nice error messages. Silently rejected.
Sigh.


More information about the Digitalmars-d-learn mailing list