[m-dev.] Higher order func mode documentation (poss. bug?)

Ralph Becket rbeck at microsoft.com
Fri Feb 4 01:03:16 AEDT 2000


I've just tried out a little test to see whether
higher-order func args default to mode 
`(in, ...) = out is det' or just `in' and it turns
out that the former is the case.  That is, I can
write

:- func foo(func(T1) = T2, T1) = T2.
foo(F, X) = F(X).

and the compiler is quite happy.  The documentation
isn't wrong, strictly speaking:

"If there is no mode declaration for a function, the 
compiler assumes a default mode for the function in 
which all the arguments have mode `in' and the result 
of the function has mode `out'. (However, there is no 
requirement that a function have such a mode; if 
there is any explicit mode declaration, it overrides 
the default.)"

since `func(in, ...) = out is det' is a special case
of `in'.  However, I think the manual should make it
clear that higher order functions will also benefit
from the default mode behaviour.

Ralph
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list