Informal interfaces

Josh Stern josh_usenet at phadd.net
Mon Oct 2 08:57:25 PDT 2006


On Mon, 02 Oct 2006 11:57:37 +0200, BLS wrote:

> Fredrik Olsson schrieb:
> 
> I like this idea.
> 
>   As Jave (And D) does not have multiple
>> inheritance this add another restriction; a delegate object can only 
>> handle a single control (or type of control), not a whole window.
> 
> Using the *Twin pattern* allow us to model multiple inheritance in 
> languages like D, Java.
> 
> A pretty straightforward example in Java  is available at :
> http://www.ssw.uni-linz.ac.at/Research/Papers/Moe99/Paper.pdf
> 

The twin pattern seem like an unattractive last resort for someone faced
with an existing language and class hierarchy.   

If one were designing solutions for the problems related to multiple
inheritance, starting from D as it is now, I'd suggest the following:

1) the flexible general solution with a small run-time overhead - allow
functions to be written using interfaces as arguments.   Implementation
could save space on the stack for what would basically be a run-time
determined vtable and lazily fill in the values as needed by the function
body;

2) efficient (time) code solution - use templates; for extra safety, allow
a mechanism for compile time checking that the template argument actually
implements the given interface rather than just having a name collision;
member templates would make this more convenient, but are not really
necessary.




More information about the Digitalmars-d mailing list