I agree, we should document it, unfortunately our documentation is still 
woefully inadequate  :(.  Maybe someone could add it to the IronPython cookbook 
page in the mean time? (http://www.ironpython.info/index.php/Main_Page).

But as for it "working in C#"...  Consider the code:

using System;

public class Foo : ICloneable {
    public object Bar() {
        return  Clone();
    }

    object ICloneable.Clone() {
        return null;
    }
}

That code doesn't compile because you must be explicit to access the Icloneable 
method.  This compiles:

using System;

public class Foo : ICloneable {
    public object Bar() {
        return  ((ICloneable)this).Clone();
    }

    object ICloneable.Clone() {
        return null;
    }
}

As does:

using System;

public class Foo : ICloneable {
    public object Bar() {
        ICloneable x = this;
        return  x.Clone();
    }

    object ICloneable.Clone() {
        return null;
    }
}

But you must explicitly refer to the type somewhere.  Unfortunately we don't 
have type information at compile time so the only way to refer to the type is 
at runtime by getting the method from the interface.  But in either case both 
languages are requiring you to be explicit about your choice of method.    So 
conceptually I think we're fairly similar.


From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Miha Valencic
Sent: Wednesday, January 23, 2008 12:28 PM
To: Discussion of IronPython
Subject: Re: [IronPython] IronPython and polymorphism? Help with interfaces

Thanks for the explanation. The docs could/should mention that... :) I guess 
we're not used, because it works in C#, so it should double-work in Ipy. You 
know, inferred types and all... :))

rgds,
 Miha.
On Jan 23, 2008 9:21 PM, Dino Viehland <[EMAIL PROTECTED]<mailto:[EMAIL 
PROTECTED]>> wrote:

It's a feature, explicit interfaces require an explicit call  :) .
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to