It is not completely correct that with fsc.exe everything is well. If you compiler just the type definition it is true nobody complains. But if you try to compile the following

1
2
3
4
type d = class new (x:int) = {} end
type d1 = class inherit d end

let v = new d1()

the compiler reports an error. The reason for the different behaviors of fsc.exe and fsi.exe is that the latter uses Reflection.Emit that performs additional checks on the well-formedness of the generated assembly that the fsc.exe does not perform. As a matter of fact both approaches are correct: unless you want create a type the types d1 and d are correct as witnessed by the peverify command. On the other hand it is not possible to have instances as reported by fsi.exe.

Although a warning may be reported in this case I think that the correct behavior is shown by fsc.exe since you may still have a type that cannot be instantiated but with static methods. Nevertheless in practice you must assume that if a type inherits from another type the construction of an object of the derived class must be able to initialize the portion inherited from the base class.

Antonio

By on 11/19/2007 1:51 PM ()

Thank you for the kind explanation. I now understand the differences.

Best regards,

keiko

By on 11/20/2007 2:44 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