Skip to main content
Version: Next

inline

The decorator @inline on a function definition informs the compiler that we that the code of said function must be inlined wherever it is called. This allows some optimisations to be performed, possibly at the expense of a larger compiled code. Benchmarks and profiling help decide whether a function should be inlined or not.

Inlining also make it cheap to create aliases of functions. For example:

@inline
const size = <elt>(list: List.t<elt>) : nat => List.length(list);