duck!

Denis Koroskin 2korden at gmail.com
Sat Oct 16 17:50:51 PDT 2010


On Sun, 17 Oct 2010 04:17:18 +0400, Andrei Alexandrescu  
<SeeWebsiteForEmail at erdani.org> wrote:

> On 10/16/2010 05:57 PM, kenji hara wrote:
>> Current dmd does not enough support runtime reflection.
> [snip]
>
> I think runtime reflection is not needed. What you'd need to do for the  
> "loose duck" is generate code that throws for all interface methods that  
> are not present in the class. Am I wrong?
>
> Andrei

interface ICanQuack
{
	void quack() { ... }
}

class Duck
{
	void quack() { .. }
}

Object o = new Duck();
Duck d = duck!(ICanQuack)(o);

d.quack(); // throw or not?


More information about the Digitalmars-d mailing list