Next: , Up: Pragmas   [Contents]


20.1 Inlining

Declarations of these forms

:- pragma inline(pred(Name/Arity)).
:- pragma inline(func(Name/Arity)).

are a hint to the compiler that all calls to the predicate or function with name Name and arity Arity should be inlined.

The current Mercury implementation is smart enough to inline simple predicates even without this hint.

Declarations of these forms

:- pragma no_inline(pred(Name/Arity)).
:- pragma no_inline(func(Name/Arity)).

tell the compiler not to inline the named predicate or function. This may be used simply for performance concerns (inlining can cause unwanted code bloat in some cases) or to prevent possibly dangerous inlining when using low-level C code.