[mercury-users] Queries which are not answered

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Oct 12 20:58:58 AEST 2002


On 12-Oct-2002, Noel  Pinto <cool4life at rediffmail.com> wrote:
> 2) In the manual, higher-order function application is a compound 
> term of the following forms:-
> apply(Func, Arg1, Arg2, ..., ArgN)
> FuncVar(Arg1, Arg2, ..., ArgN)
> I want to know whether apply and FuncVar would be declared as 
> 'pred' or 'func'.

Short answer: as 'func'.

Long answer:
FuncVar is, as the name suggests, a variable, so it does not need to be
declared at all.  However, its type will be a higher-order function type.

"apply" is a built-in language construct; it does not need to be
(and in fact is not) declared.  However, it is analagous to a
family of functions with the same name and different arities
(numbers of arguments) which could be declared as follows:

	:- func apply((func) = T) = T.
	:- func apply(func(T1) = T, T1) = T.
	:- func apply(func(T1, T2) = T, T1, T2) = T.
	:- func apply(func(T1, T2, T3) = T, T1, T2, T3) = T.
	% etc. ad infinitum

So yes, it corresponds to something which could be declared as `func'.
(The corresponding construct for predicates is "call"; see the
"calling higher-order terms" section of the language reference manual.)

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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