Ducks

Francesco Cattoglio francesco.cattoglio at gmail.com
Thu Feb 6 00:06:40 PST 2014


On Thursday, 6 February 2014 at 01:01:59 UTC, Chris Williams 
wrote:
> I think that the advantages that are added by template-based 
> compilability checks can be gained without losing flexibility 
> if we add a more lenient interface definition, like:

I love the idea of some kind of "static interface" too. Pretty 
sure it would also allow better compile-time polymorphism. The 
problem I see with this proposal however is that the chances of 
getting it into the core language are zero.
Perhaps one could get a library solution if what we are looking 
for is extra clarity.

Something like

void DoSomething(T)(T t)
if (DuckTyping(T, MyType)
{
     ... stuff ...
}


More information about the Digitalmars-d mailing list