Hi, I just answered another question regarding the class syntax, so you may want to check it out here: http://cs.hubfs.net/forums/thread/6936.aspx.
Inheriting from types without parameterless constructor is possible using the explicit syntax (your MyForm1) as well. You just have to call the base constructor in your constructor (eg. new() = { inherit Form(123); a = 10 })
In general, the first syntax is there if you need to define some class in the same way as you'd do in C#. It allows writing a few things that cannot be done using the second syntax and it is useful for example for CodeDOM, but there are really only a few things that cannot be done using the implicit syntax, so the implicit syntax is preferred, unless you really need something special. Your second example can be written more nicely like this:
type MyForm2() as t = // 't' is 'this' reference
inherit Form()
let button2 = new Button()
// local function declaration (not visible from outside of the class)
let foo () =
10
// initialization in the 'constructor'
do
t.Controls.Add button2
member x.Foo () = foo () // Usual public member - can use local functions
let form2 = new MyForm2()
form2.Show()
Tomas Petricek (
Blog), C# MVP
My book:
Real-world Functional Programming in .NET