Automatic Interface Implementation

JS js.mdnq at gmail.com
Fri Jul 5 15:43:05 PDT 2013


On Friday, 5 July 2013 at 22:33:01 UTC, Vladimir Panteleev wrote:
> On Friday, 5 July 2013 at 17:53:11 UTC, JS wrote:
>> I ripped and hacked up some code from typecons that allows one 
>> to implement an interface automatically by redirecting it to a 
>> variable implementing the interface.
>
> How about splitting up the implementation of AutoImplement into 
> a template mixin, which would then be usable on its own?
>
> Some previous discussion on the topic:
>
> http://forum.dlang.org/post/20100909021137.40d2dce2.rsinfu@gmail.com
>
> The new "wrap" from std.typecons looks like it might help, 
> however:
> 1) The type it creates is completely inaccessible (the return 
> type is the interface);
> 2) It doesn't seem to play well with "alias this". Instead of 
> wrapping methods in the struct containing "alias this", it uses 
> the methods (with the same name/signature) from the object 
> "alias this" points to.

I took the code from the latest std.typecons wrap and modified 
it(well, after initially doing my own interface). I just needed a 
quick implementation.

std.typecon has a lot of goodies in it but it seems to 
re-implement much of the same functionality in many of the 
templates.

wrap did not compile do I took out the stuff that didn't work and 
hacked it up to get what I needed out of it.


More information about the Digitalmars-d mailing list