[mercury-users] higher order syntax

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Feb 12 19:22:13 AEDT 2000


On 11-Feb-2000, Peter Schachte <schachte at cs.mu.OZ.AU> wrote:
> 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?

I think that would probably cause at least as many problems as it would solve.
For example, if you write 

	bop (X(Y)) ...

where `bop' is a binary prefix operator, then surely the parser
should treat the ''(X, Y) term as only the first argument to
the operator, rather than counting it as two arguments.

I think it is OK for `bop (X)(Y)' to be a syntax error.
I don't mind requiring users to add some whitespace in
such situations, since after all it is good style to do so anyway.
And if anything the new rules would make it more consistent,
since `bop(X)(Y)' and `bop(X) (Y)' are currently syntax errors.

So I like Ralph's proposal.

> But how would p(W,X)(Y,Z) be parsed?
> Maybe ''(p(W,X),Y,Z) ?

Yes.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- 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