duck!

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sat Oct 16 18:13:36 PDT 2010


On 10/16/2010 07:50 PM, Denis Koroskin wrote:
> 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?

Throw... but now I see what Kenji meant. Thanks! So really there's three 
levels:

- statically-enforced conformance

- statically-decided conformance

- dynamically-decided conformance

Now we have three names to find, not one :o).


Andrei


More information about the Digitalmars-d mailing list