I don't think you can use interfaces to achieve polymorphism with respect to more than argument. Consider the problem of defining the interface of addition:

1
2
type ISummable =
    abstract Add: ISummable -> ISummable 

This is not so nice, as this implies that each implementation A of ISummable must support addition with any other implementation B of ISummable.

Another minor problem with this approach is that the specification of addition is not symmetric, one of the instances of ISummable must play the role of the "this".

With respect to performance, I wonder if the interface approach might not be better though. I am guessing here, but I expect the CLR may be able (some day) to optimize calls to virtual methods, but I don't expect it would do so with a dictionary object.

By on 10/10/2008 9:43 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper