¿Te gusta?
type MyType(x:int, s:string) =
public new() = MyType(42,"forty-two")
member this.X = x
member this.S = s
let foo = new MyType(1,"one")
let bar = new MyType()
printfn "%d %s" foo.X foo.S
printfn "%d %s" bar.X bar.S
Esta es la forma típica de hacerlo. Haga que el constructor "más parametrizable" sea el constructor implícito, y el resto sean sobrecargas "nuevas" definidas como miembros en la clase que llama al constructor implícito.
EDITAR
Hay un error en la Beta 2 en relación con las clases abstractas. En algunas circunstancias se puede evitar usando los argumentos por defecto en el constructor implícita, a la
[<AbstractClass>]
type MyType(?cx:int, ?cs:string) =
let x = defaultArg cx 42
let s = defaultArg cs "forty-two"
member this.X = x
member this.S = s
abstract member Foo : int -> int
type YourType(x,s) =
inherit MyType(x,s)
override this.Foo z = z + 1
type TheirType() =
inherit MyType()
override this.Foo z = z + 1
let foo = new YourType(1,"one")
let bar = new TheirType()
printfn "%d %s" foo.X foo.S
printfn "%d %s" bar.X bar.S
+1: "parameterfull" :) – Juliet