[mercury-users] higher order syntax

Peter Schachte schachte at cs.mu.OZ.AU
Fri Feb 11 16:26:45 AEDT 2000

On Fri, Feb 11, 2000 at 03:12:36PM +1100, Fergus Henderson wrote:
> On 10-Feb-2000, Ralph Becket <rbeck at microsoft.com> wrote:
> > The mercury syntax allows us to write `P(...)' and
> > `F(...)' in place of `call(P, ...)' and `apply(F, ...)'
> > respectively, provided P/F are *variables*
> > bound to predicate/function values.
> > Similarly, if F has type `func(T1) = (func(T2) = T3)'
> > then I have to write `apply(F(X), Y)'.
> The main difficulty with that would be with binary prefix
> operators.  If `op' is a binary prefix operator, how should
> 	op (X)(Y)
> be parsed?  Currently it gets parsed as 'op'(X, Y).
> With your proposal, I guess the (X)(Y) would be parsed
> as ''(X, Y), and so the example above would be a syntax error,
> since it uses a binary prefix operator with only one operand.

Can't you fix that by making binary prefix ops expect one argument
which must be a ''/2 term?  But how would p(W,X)(Y,Z) be parsed?
Maybe ''(p(W,X),Y,Z) ?

Basically, I like this idea (I've thought it would be useful, too).
But I'm concerned about the ambiguity problems between a nilary
function returning a function or predicate and a first-order function
or predicate.  For example:

	:- pred p(int).
	:- func p = pred(int).

now what does the goal p(3) mean?  Do you apply the predicate returned
by the p/0 function to 3, or do you invoke the predicate p/1?  I guess
this is just the usual ambiguous overloading problem and can be
handled the same way, but somehow it seems more confusing.

Peter Schachte                     Any man who is under 30, and is not a
mailto:schachte at cs.mu.OZ.AU        liberal, has not heart; and any man who
http://www.cs.mu.oz.au/~schachte/  is over 30, and is not a conservative,
PGP: finger schachte at  has no brains. -- Winston Churchill 
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