Is it possible to tell the OCaml compiler to inline a function, instead of hoping that its optimization process will do so itself?
Inline function and classes: If you need to explicitly declare inline function in the class then just declare the function inside the class and define it outside the class using inline keyword.
Press ⌥⌘N (macOS), or Ctrl+Alt+N (Windows/Linux), to inline a method.
DATA - Inline Declaration - ABAP Keyword Documentation. A declaration expression with the declaration operator DATA declares a variable var used as an operand in the current writing position. The declared variable is visible statically in the program from the location DATA(var) and is valid in the current context.
An inline function is one for which the compiler copies the code from the function definition directly into the code of the calling function rather than creating a separate set of instructions in memory. This eliminates call-linkage overhead and can expose significant optimization opportunities.
You can both add an attribute to always inline a function
let f x = x [@@inline always]
(* which is equivalent to *)
let f x = x [@@inline]
or force a specific call to be inlined with another attribute
let a = (f[@inlined]) 1
If you want to check inlining decisions made by flambda, you can use the inlining-report
flag.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With