F#中的对象表达和捕获状态

nic*_*las 5 f# interface

是什么让第一次实施KO?

type IToto  = 
    abstract Toto : unit -> unit

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

{ new IToto with  
        member this.Toto () = ()  }
Run Code Online (Sandbox Code Playgroud)

Tom*_*cek 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 () -> () }
Run Code Online (Sandbox Code Playgroud)