5

是什么让第一个实现 KO ?

type IToto  = 
    abstract Toto : unit -> unit

{ new IToto with  
      member this.Toto = 
             fun () -> () }

{ new IToto with  
        member this.Toto () = ()  }
4

1 回答 1

6

FSharpFunc<unit, unit> Toto { get; }在编译表示中,函数类型的属性(编译为)和获取单位和返回单元的方法(编译为 )之间存在差异unit Toto()

第一个对象表达式实现了一个不同的接口:

type IToto  = 
    abstract Toto : (unit -> unit) // Note: Parentheses around the function type!

{ new IToto with  
      member this.Toto = 
             fun () -> () }
于 2013-03-06T11:56:17.970 回答