[mercury-users] Idea for another handy convention (preds, this time).

Ralph Becket rbeck at microsoft.com
Thu Jul 27 02:10:39 AEST 2000


The language specifies that a function

:- func f(A, B, C) = Z.

lacking a mode declaration is assumed to have the conventional
mode, namely

:- mode f(in, in, in) = out is det.

This is especially handy for function lambdas.

I would like to propose a similar default for preds, namely
that a predicate

:- pred p(A, B, C).

lacking a mode declaration is assumed to have the conventional
(in most other languages) mode of

:- mode p(in, in, in) is semidet.

This would also do away with the need for excess verbiage in
many predicate lambdas, for example:

	Evens = list__filter((pred(X) :- X mod 2 = 0), Xs).

which, in my book, is preferable to

	Evens = list__filter((pred(X::in) is semidet :- X mod 2 = 0), Xs).

The default for functions is to only require explicit mode
declarations when something `unusual' is going on; I propose
we extend this idea to predicates as well.

Ralph
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list