tags:

views:

119

answers:

1
type IFooable =
  abstract Foo : int -> int

type IFooable2 =
  abstract Foo : a : int -> int

type MyClass() =
    interface IFooable2 with
        member this.Foo(b) = 7

What is the difference between IFooable and IFooable2 ? Are they equivalent ? What is the purpose of it in the case of my example ? When to use it ?

+4  A: 

IFooable2 names its parameter; IFooable does not.

This matters when systems reflect on parameter names. As an example, when you use WCF with an interface type marked up with ServiceContractAttribute, by default WCF uses the parameter names in the interface to control the names that appear in the XML projection of data on the wire.

This also matter for tooling, for example, reference this F# code from C#, declare a variable of each type, and look at the intellisense tooltips on each method.

I'd recommend always declaring the parameter name (prefer the second version).

Brian