Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/fsharp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
当嵌套是可选的时,嵌套f#函数与不嵌套f#函数有何不同?_F#_Inline - Fatal编程技术网

当嵌套是可选的时,嵌套f#函数与不嵌套f#函数有何不同?

当嵌套是可选的时,嵌套f#函数与不嵌套f#函数有何不同?,f#,inline,F#,Inline,我理解当您想要返回闭包时嵌套函数的好处。但是,当一个函数从未在其定义的函数之外使用时,保持它嵌套是否有成本 考虑: let private validate number = number > 100 let validateAndPrint (i : int) = printfn "%i Greater than 100: %s" i ((validate i).ToString()) 与: let validateAndPrint (i : int) =

我理解当您想要返回闭包时嵌套函数的好处。但是,当一个函数从未在其定义的函数之外使用时,保持它嵌套是否有成本

考虑:

let private validate number = 
    number > 100

let validateAndPrint (i : int) = 
    printfn "%i Greater than 100: %s" i ((validate i).ToString())
与:

let validateAndPrint (i : int) = 
    let validate number = 
        number > 100
    printfn "%i Greater than 100: %s" i ((validate i).ToString())
这里的问题通常是当我有一些内部函数时,我只需要根据执行路径调用其中一个(通常不禁止将这些函数保持私有或嵌套并测试排列)

validateAndPrint
也可以重写为更便于tdd的格式,以使用验证功能:

let validateAndPrint validate i = ...
..但是如果
验证
的签名包含内部或私有类型,则需要考虑将所有内容公开,并将参数列表放大


有什么重要区别吗?

发布
模式中,IL是相同的,
验证
的两个版本都在这个特定示例中内联

您不能总是依赖内联,例如,如果一个函数是“大”的,那么编译器可以选择不内联它(这对于方法是正确的,我不能100%确定这对于F#嵌套函数是正确的。不可能将它们标记为
inline
并强制内联,-如果这些函数的行为类似于方法或在发行版中始终内联,则需要参考F#规范)。在调试模式下的嵌套情况下,有额外的FSharpFunc分配和
callvirt
。没有嵌套,它只是一个没有分配的静态调用,这是所有可能实现中最便宜的

因此,一般来说,如果嵌套是真正可选的,那么避免嵌套会更安全,因为即使函数没有内联,它也总是作为静态方法调用。然而,只有当您每秒调用此代码数百万次时,它才起作用

在IL0019上的非嵌套静态调用:

.method public static 
    void validateAndPrint (
        int32 i
    ) cil managed 
{
    // Method begins at RVA 0x2104
    // Code size 51 (0x33)
    .maxstack 5
    .locals init (
        [0] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>,
        [1] bool
    )

    IL_0000: ldstr "%i Greater than 100: %s"
    IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [mscorlib]System.Tuple`2<int32, string>>::.ctor(string)
    IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<!!0, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit>)
    IL_000f: stloc.0
    IL_0010: nop
    IL_0011: ldloc.0
    IL_0012: newobj instance void FSSO.Test/validateAndPrint@8::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>)
    IL_0017: ldarg.0
    IL_0018: ldarg.0
    IL_0019: call bool FSSO.Test::validate(int32)
    IL_001e: stloc.1
    IL_001f: ldloca.s 1
    IL_0021: constrained. [mscorlib]System.Boolean
    IL_0027: callvirt instance string [mscorlib]System.Object::ToString()
    IL_002c: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, string>::InvokeFast<class [FSharp.Core]Microsoft.FSharp.Core.Unit>(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!0, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!1, !!0>>, !0, !1)
    IL_0031: pop
    IL_0032: ret
} // end of method Test::validateAndPrint
.method public static 
    void validateAndPrint (
        int32 i
    ) cil managed 
{
    // Method begins at RVA 0x2050
    // Code size 58 (0x3a)
    .maxstack 6
    .locals init (
        [0] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, bool> validate,
        [1] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>,
        [2] bool
    )

    IL_0000: newobj instance void FSSO.Test2/validate@13::.ctor()
    IL_0005: stloc.0
    IL_0006: ldstr "%i Greater than 100: %s"
    IL_000b: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [mscorlib]System.Tuple`2<int32, string>>::.ctor(string)
    IL_0010: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<!!0, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit>)
    IL_0015: stloc.1
    IL_0016: nop
    IL_0017: ldloc.1
    IL_0018: newobj instance void FSSO.Test2/'validateAndPrint@14-2'::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>)
    IL_001d: ldarg.0
    IL_001e: ldloc.0
    IL_001f: ldarg.0
    IL_0020: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, bool>::Invoke(!0)
    IL_0025: stloc.2
    IL_0026: ldloca.s 2
    IL_0028: constrained. [mscorlib]System.Boolean
    IL_002e: callvirt instance string [mscorlib]System.Object::ToString()
    IL_0033: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, string>::InvokeFast<class [FSharp.Core]Microsoft.FSharp.Core.Unit>(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!0, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!1, !!0>>, !0, !1)
    IL_0038: pop
    IL_0039: ret
} // end of method Test2::validateAndPrint
.method public static 
    void validateAndPrint (
        int32 i
    ) cil managed 
{
    // Method begins at RVA 0x2050
    // Code size 57 (0x39)
    .maxstack 6
    .locals init (
        [0] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>,
        [1] class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit>,
        [2] bool
    )

    IL_0000: ldstr "%i Greater than 100: %s"
    IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [mscorlib]System.Tuple`2<int32, string>>::.ctor(string)
    IL_000a: stloc.1
    IL_000b: call class [mscorlib]System.IO.TextWriter [mscorlib]System.Console::get_Out()
    IL_0010: ldloc.1
    IL_0011: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>>(class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<!!0, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit>)
    IL_0016: stloc.0
    IL_0017: nop
    IL_0018: ldloc.0
    IL_0019: newobj instance void FSSO.Test2/'validateAndPrint@14-2'::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>)
    IL_001e: ldarg.0
    IL_001f: ldarg.0
    IL_0020: ldc.i4.s 100
    IL_0022: cgt
    IL_0024: stloc.2
    IL_0025: ldloca.s 2
    IL_0027: constrained. [mscorlib]System.Boolean
    IL_002d: callvirt instance string [mscorlib]System.Object::ToString()
    IL_0032: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, string>::InvokeFast<class [FSharp.Core]Microsoft.FSharp.Core.Unit>(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!0, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!1, !!0>>, !0, !1)
    IL_0037: pop
    IL_0038: ret
} // end of method Test2::validateAndPrint
.method公共静态
无效验证数据点(
int32 i
)cil管理
{
//方法从RVA 0x2104开始
//代码大小51(0x33)
.maxstack 5
.init(
[0]类[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,
[1] 布尔
)
IL_0000:ldstr“%i大于100:%s”
IL_0005:newobj实例无效类[FSharp.Core]Microsoft.FSharp.Core.printformat`5::.ctor(字符串)
IL_000a:call!!0[FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::printformaline(类[FSharp.Core]Microsoft.FSharp.Core.printformat`4)
IL_000f:stloc.0
IL_0010:没有
IL_0011:ldloc.0
IL_0012:newobj实例无效FSSO.Test/validateAndPrint@8:.ctor(类[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2)
IL_0017:ldarg.0
IL_0018:ldarg.0
IL_0019:调用bool FSSO.Test::validate(int32)
IL_001e:stloc.1
IL_001f:ldloca.s 1
IL_0021:受约束的[mscorlib]System.Boolean
IL_0027:callvirt实例字符串[mscorlib]System.Object::ToString()
调用!!0类[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(类[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>,!0,!1)
IL_0031:流行音乐
IL_0032:ret
}//方法测试结束::validateAndPrint
嵌套,IL_0018上的分配和IL_0020上的callvirt:

.method public static 
    void validateAndPrint (
        int32 i
    ) cil managed 
{
    // Method begins at RVA 0x2104
    // Code size 51 (0x33)
    .maxstack 5
    .locals init (
        [0] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>,
        [1] bool
    )

    IL_0000: ldstr "%i Greater than 100: %s"
    IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [mscorlib]System.Tuple`2<int32, string>>::.ctor(string)
    IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<!!0, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit>)
    IL_000f: stloc.0
    IL_0010: nop
    IL_0011: ldloc.0
    IL_0012: newobj instance void FSSO.Test/validateAndPrint@8::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>)
    IL_0017: ldarg.0
    IL_0018: ldarg.0
    IL_0019: call bool FSSO.Test::validate(int32)
    IL_001e: stloc.1
    IL_001f: ldloca.s 1
    IL_0021: constrained. [mscorlib]System.Boolean
    IL_0027: callvirt instance string [mscorlib]System.Object::ToString()
    IL_002c: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, string>::InvokeFast<class [FSharp.Core]Microsoft.FSharp.Core.Unit>(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!0, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!1, !!0>>, !0, !1)
    IL_0031: pop
    IL_0032: ret
} // end of method Test::validateAndPrint
.method public static 
    void validateAndPrint (
        int32 i
    ) cil managed 
{
    // Method begins at RVA 0x2050
    // Code size 58 (0x3a)
    .maxstack 6
    .locals init (
        [0] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, bool> validate,
        [1] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>,
        [2] bool
    )

    IL_0000: newobj instance void FSSO.Test2/validate@13::.ctor()
    IL_0005: stloc.0
    IL_0006: ldstr "%i Greater than 100: %s"
    IL_000b: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [mscorlib]System.Tuple`2<int32, string>>::.ctor(string)
    IL_0010: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<!!0, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit>)
    IL_0015: stloc.1
    IL_0016: nop
    IL_0017: ldloc.1
    IL_0018: newobj instance void FSSO.Test2/'validateAndPrint@14-2'::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>)
    IL_001d: ldarg.0
    IL_001e: ldloc.0
    IL_001f: ldarg.0
    IL_0020: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, bool>::Invoke(!0)
    IL_0025: stloc.2
    IL_0026: ldloca.s 2
    IL_0028: constrained. [mscorlib]System.Boolean
    IL_002e: callvirt instance string [mscorlib]System.Object::ToString()
    IL_0033: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, string>::InvokeFast<class [FSharp.Core]Microsoft.FSharp.Core.Unit>(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!0, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!1, !!0>>, !0, !1)
    IL_0038: pop
    IL_0039: ret
} // end of method Test2::validateAndPrint
.method public static 
    void validateAndPrint (
        int32 i
    ) cil managed 
{
    // Method begins at RVA 0x2050
    // Code size 57 (0x39)
    .maxstack 6
    .locals init (
        [0] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>,
        [1] class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit>,
        [2] bool
    )

    IL_0000: ldstr "%i Greater than 100: %s"
    IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [mscorlib]System.Tuple`2<int32, string>>::.ctor(string)
    IL_000a: stloc.1
    IL_000b: call class [mscorlib]System.IO.TextWriter [mscorlib]System.Console::get_Out()
    IL_0010: ldloc.1
    IL_0011: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>>(class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<!!0, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit>)
    IL_0016: stloc.0
    IL_0017: nop
    IL_0018: ldloc.0
    IL_0019: newobj instance void FSSO.Test2/'validateAndPrint@14-2'::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>)
    IL_001e: ldarg.0
    IL_001f: ldarg.0
    IL_0020: ldc.i4.s 100
    IL_0022: cgt
    IL_0024: stloc.2
    IL_0025: ldloca.s 2
    IL_0027: constrained. [mscorlib]System.Boolean
    IL_002d: callvirt instance string [mscorlib]System.Object::ToString()
    IL_0032: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, string>::InvokeFast<class [FSharp.Core]Microsoft.FSharp.Core.Unit>(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!0, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!1, !!0>>, !0, !1)
    IL_0037: pop
    IL_0038: ret
} // end of method Test2::validateAndPrint
.method公共静态
无效验证数据点(
int32 i
)cil管理
{
//方法从RVA 0x2050开始
//代码大小58(0x3a)
.maxstack 6
.init(
[0]类[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2验证,
[1] 类[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,
[2] 布尔
)
IL_0000:newobj实例void FSSO.Test2/validate@13:.ctor()
IL_0005:stloc.0
IL_0006:ldstr“%i大于100:%s”
IL_000b:newobj实例无效类[FSharp.Core]Microsoft.FSharp.Core.printformat`5::.ctor(字符串)
IL_0010:call!!0[FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::printformaline(类[FSharp.Core]Microsoft.FSharp.Core.printformat`4)
IL_0015:stloc.1
IL_0016:没有
IL_0017:ldloc.1
IL_0018:newobj实例void FSSO.Test2/'validateAndPrint@14-2'::.ctor(类[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2)
IL_001d:ldarg.0
IL_001e:ldloc.0
IL_001f:ldarg.0
IL_0020:callvirt实例!1类[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::Invoke(!0)
IL_0025:stloc.2
IL_0026:ldloca.s 2
IL_0028:受约束的[mscorlib]System.Boolean
IL_002e:callvirt实例字符串[mscorlib]System.Object::ToString()
IL_0033:call!!0类[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2::InvokeFast(类[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2>,!0,!1)
IL_0038:流行音乐
IL_0039:ret
}//方法Test2的结尾::validateAndPrint
发布模式,IL_0020上的内联比较:

.method public static 
    void validateAndPrint (
        int32 i
    ) cil managed 
{
    // Method begins at RVA 0x2104
    // Code size 51 (0x33)
    .maxstack 5
    .locals init (
        [0] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>,
        [1] bool
    )

    IL_0000: ldstr "%i Greater than 100: %s"
    IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [mscorlib]System.Tuple`2<int32, string>>::.ctor(string)
    IL_000a: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<!!0, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit>)
    IL_000f: stloc.0
    IL_0010: nop
    IL_0011: ldloc.0
    IL_0012: newobj instance void FSSO.Test/validateAndPrint@8::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>)
    IL_0017: ldarg.0
    IL_0018: ldarg.0
    IL_0019: call bool FSSO.Test::validate(int32)
    IL_001e: stloc.1
    IL_001f: ldloca.s 1
    IL_0021: constrained. [mscorlib]System.Boolean
    IL_0027: callvirt instance string [mscorlib]System.Object::ToString()
    IL_002c: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, string>::InvokeFast<class [FSharp.Core]Microsoft.FSharp.Core.Unit>(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!0, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!1, !!0>>, !0, !1)
    IL_0031: pop
    IL_0032: ret
} // end of method Test::validateAndPrint
.method public static 
    void validateAndPrint (
        int32 i
    ) cil managed 
{
    // Method begins at RVA 0x2050
    // Code size 58 (0x3a)
    .maxstack 6
    .locals init (
        [0] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, bool> validate,
        [1] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>,
        [2] bool
    )

    IL_0000: newobj instance void FSSO.Test2/validate@13::.ctor()
    IL_0005: stloc.0
    IL_0006: ldstr "%i Greater than 100: %s"
    IL_000b: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [mscorlib]System.Tuple`2<int32, string>>::.ctor(string)
    IL_0010: call !!0 [FSharp.Core]Microsoft.FSharp.Core.ExtraTopLevelOperators::PrintFormatLine<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>>(class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<!!0, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit>)
    IL_0015: stloc.1
    IL_0016: nop
    IL_0017: ldloc.1
    IL_0018: newobj instance void FSSO.Test2/'validateAndPrint@14-2'::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>)
    IL_001d: ldarg.0
    IL_001e: ldloc.0
    IL_001f: ldarg.0
    IL_0020: callvirt instance !1 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, bool>::Invoke(!0)
    IL_0025: stloc.2
    IL_0026: ldloca.s 2
    IL_0028: constrained. [mscorlib]System.Boolean
    IL_002e: callvirt instance string [mscorlib]System.Object::ToString()
    IL_0033: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, string>::InvokeFast<class [FSharp.Core]Microsoft.FSharp.Core.Unit>(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!0, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!1, !!0>>, !0, !1)
    IL_0038: pop
    IL_0039: ret
} // end of method Test2::validateAndPrint
.method public static 
    void validateAndPrint (
        int32 i
    ) cil managed 
{
    // Method begins at RVA 0x2050
    // Code size 57 (0x39)
    .maxstack 6
    .locals init (
        [0] class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>,
        [1] class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit>,
        [2] bool
    )

    IL_0000: ldstr "%i Greater than 100: %s"
    IL_0005: newobj instance void class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`5<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [mscorlib]System.Tuple`2<int32, string>>::.ctor(string)
    IL_000a: stloc.1
    IL_000b: call class [mscorlib]System.IO.TextWriter [mscorlib]System.Console::get_Out()
    IL_0010: ldloc.1
    IL_0011: call !!0 [FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter<class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>>(class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.PrintfFormat`4<!!0, class [mscorlib]System.IO.TextWriter, class [FSharp.Core]Microsoft.FSharp.Core.Unit, class [FSharp.Core]Microsoft.FSharp.Core.Unit>)
    IL_0016: stloc.0
    IL_0017: nop
    IL_0018: ldloc.0
    IL_0019: newobj instance void FSSO.Test2/'validateAndPrint@14-2'::.ctor(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<string, class [FSharp.Core]Microsoft.FSharp.Core.Unit>>)
    IL_001e: ldarg.0
    IL_001f: ldarg.0
    IL_0020: ldc.i4.s 100
    IL_0022: cgt
    IL_0024: stloc.2
    IL_0025: ldloca.s 2
    IL_0027: constrained. [mscorlib]System.Boolean
    IL_002d: callvirt instance string [mscorlib]System.Object::ToString()
    IL_0032: call !!0 class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<int32, string>::InvokeFast<class [FSharp.Core]Microsoft.FSharp.Core.Unit>(class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!0, class [FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2<!1, !!0>>, !0, !1)
    IL_0037: pop
    IL_0038: ret
} // end of method Test2::validateAndPrint
.method公共静态
无效验证数据点(
int32 i
)cil管理
{
//方法从RVA 0x2050开始
//代码大小57(0x39)
.maxstack 6
.init(
[0]类[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2,
[1] 类[FSharp.Core]Microsoft.FSharp.Core.printformat`4,
[2] 布尔
)
IL_0000:ldstr“%i大于100:%s”
IL_0005:newobj实例无效类[FSharp.Core]Microsoft.FSharp.Core.printformat`5::.ctor(字符串)
IL_000a:stloc.1
IL_000b:call class[mscorlib]System.IO.TextWriter[mscorlib]System.Console::get_Out()
IL_0010:ldloc.1
IL_0011:call!!0[FSharp.Core]Microsoft.FSharp.Core.PrintfModule::PrintFormatLineToTextWriter(类[mscorlib]System.IO.TextWriter,类[FSharp.Core]Microsoft.FSharp.Core.printformat`4)
IL_0016:stloc.0
IL_0017:没有
IL_0018:ldloc.0
IL_0019:newobj实例void FSSO.Test2/'validateAndPrint@14-2'::.ctor(类[FSharp.Core]Microsoft.FSharp.Core.FSharpFunc`2)
IL_001e:ldarg.0
IL_001f:ldarg.0
IL_0020:ldc.i4.s 100
IL_0022:cgt
IL_0024:stloc.2
IL_0025:ldloca.s 2
伊卢00