Yes, the OCaml object system is structrual, while the F# and .NET object systems are nominal.

In principle member constraints can be used in the way you describe. However, member constraints are really only currently for use in the F# library, particularly for operator overloading. So using them extensively is not recommended. This is also because of the restrictions related to inlining, which in particular means member constraints can't be associated with the type paramaters of classes.

Your second example needs to be

1
2
3
4
5
6
 

let x = new DoingFoo();;
(x :> IFoo).exec() ;;

That is, interface members aren't automatically visible on class types - the interface must be explicitly revealed.

Re #light: yes, a detailed set of rules is in progress, and the particular problem with "else" that means that the following block does not need to be indented has already been noted. Please send us bug reports of any oddities.

Cheers!

don

By on 10/22/2006 1:53 PM ()
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