Next: , Previous: Builtin higher-order insts and modes, Up: Higher-order insts and modes   [Contents]


8.3.2 Default insts for functions

In order to call a higher-order term, the compiler must know its higher-order inst. This can cause problems when higher-order terms are placed into a polymorphic collection type and then extracted, since the declared mode for the extraction will typically be out and the higher-order inst information will be lost. To partially alleviate this problem, and to make higher-order functional programming easier, if the term to be called has a function type, but no higher-order inst information is explicitly provided, we assume that it has the default higher-order function inst ‘func(in, …, in) = out is det’.

As a consequence of this, a higher-order function term can only be passed where a term with no higher-order inst information is expected if it can be passed where a term with the default higher-order function inst is expected. Higher-order predicate terms can always be passed to such a place, but note that there is little value in doing so because there is no default higher-order inst for predicates therefore it will not be possible to call those terms.