F # automatically includes some functions, even if they are not marked with `inline`, is that intended?

It seems that F # automatically builds some functions, even if they are not marked "inline".

let ax= x + 3 let bx= x * x let funB xy = if x > y then 3 else 1 let funC x = let s = ax let c = funB s (bx) c + 1 

Checking IL, I see that the compiler aggressively funB and a,b

 funC: IL_0000: nop IL_0001: ldarg.0 IL_0002: ldc.i4.3 IL_0003: add IL_0004: stloc.0 // s IL_0005: ldarg.0 IL_0006: ldarg.0 IL_0007: mul IL_0008: stloc.1 IL_0009: ldloc.0 // s IL_000A: ldloc.1 IL_000B: ble.s IL_0011 IL_000D: ldc.i4.3 IL_000E: nop IL_000F: br.s IL_0013 IL_0011: ldc.i4.1 IL_0012: nop IL_0013: ldc.i4.1 IL_0014: add IL_0015: ret 

The behavior looks strange to me. I thought that the compiler should only be built-in if there is an inline . Are there any references to her?

+4
source share
1 answer

The inline is a way to force the compiler to embed a function and as a result allows the function to take a type as a parameter and improve performance. There is no reason for the compiler to not perform the built-in functions as it sees fit for the release build.

+2
source

Source: https://habr.com/ru/post/1493876/


All Articles