LazyInterface (simplified Boost.Interfaces)

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Sep 23 07:35:06 PDT 2010


On 9/23/10 8:09 CDT, kenji hara wrote:
> I implemented adaptTo .
>
> http://github.com/9rnsr/scrap/blob/master/interfaces/interfaces.d
>
> Kenji Hara

This is great work, Kenji! I'm very glad about this because it uses 
introspection to implement an important feature. Such post-hoc interface 
binding is a core feature in quite a few languages.

If you agree, I am committed to advocate adopting this abstraction for 
Phobos in module std.typecons, with credit.

All - a bit of bikeshedding - what is a better name for adaptTo? I know 
there is a consecrated name for such late matching of an interface, but 
I can't remember it.

A few nits about the implementation:

* In line 73 it looks like you don't support covariance of return types. 
Could you fix that? Example (add it to the unittests, too):

class C
{
   long draw(){ return 10; }
}
interface Drawable
{
   int draw();
}

The override should be legit.

* Throughout: everything that is a value should start with a lowercase 
letter; everything that is not a value (e.g. type, type tuple) should 
start with an uppercase letter. In particular your "result" convention 
should use "Result" for type results and "result" for value results.

* Code shouldn't use uppercase "i" as a symbol name - it's confusable 
with "1".

Congratulations! This is great work indeed.


Thanks,

Andrei


More information about the Digitalmars-d mailing list