To interface or not to interface

Alex Makhotin alex at bitprox.com
Mon May 24 22:35:17 PDT 2010


Walter Bright wrote:
>  
> The extra complexity is in the container supporting very different ways 
> to do the same thing.
> 

A I understand from the current discussion, interfaces meet a strong 
debate. And yes, I also understand that the interfaces are considered 
unnecessary bloat that makes execution speed slower which is critical 
for performance.
Personally, I think they should be accessible.

But, can there be a compromise to satisfy both sides?

To illustrate the idea:
C# has a feature called "Partial types".
A little excerpt from C# 4.0 specs(page 285):
> The partial modifier indicates that additional parts of the type declaration may exist elsewhere, but the existence of such additional parts is not a requirement;

I see as a potential benefit for the D to have some sort of it.

For those who need templates for speed, or any other motive:

1. Import .di header with needed partial declaration of the required type.
2. The compiler injects exactly the code generated from the 
implementation of the header and nothing more.

For those who need interfaces for the reasons of maintainability, 
compatibility and interoperability:

1. Import .di header with needed partial declaration of the required 
type interfaces.
2. The compiler injects exactly the code generated from the 
implementation of the header or links with the provided library with the 
exact implementation.

The user source includes required .di header, which declares partial 
type declarations. The specified partial types from the header may have 
the implementation, but this should not be a requirement. In case of 
partially not implemented type the user gets 'not implemented' error, 
linkage fault, or something similar.

Is there a possibility for such solution?


-- 
Alex Makhotin,
the founder of BITPROX,
http://bitprox.com


More information about the Digitalmars-d mailing list