[mercury-users] Pred defns

Ralph Becket rwab1 at cam.sri.com
Fri Apr 3 18:57:24 AEST 1998


Fergus Henderson wrote on 3 Apr:
> 
> Actually, it would make more sense to write "..., $foo,$, ..."
> rather than "..., $,$foo, ...".
> So how about if a single unadorned "$" in an argument list refered
> to the next state of the accumulator in the previous argument.
> e.g.
> 	update($foo, $, $bar, $),	% you can insert spaces after all
> 	update($foo, $, $bar, $),	% the commas, if you prefer
> 	...

Oh dear God no!  We're going to end up with Perl!

If we're going to have explicit accumulator naming, how about this?

:- pred p(...) + [a, b, c].	% + Accumulators in the head.

p(...) + [p, q, r] :-		% + Local accumulators.
	a = !a + 1,
	p = 2,
	q = !p + !a,
	...

mimicing the dereferencing operator ! of ML.  `!a' denotes the current
value of acc. a while plain `a' denotes the `next' value.

If we're going to have this facility at all I strongly feel that it
should look simple and *elegant*!

Time for my anti-aesthetics pill...

Ralph

-- 
Ralph Becket  |  rwab1 at cam.sri.com  |  http://www.cam.sri.com/people/becket.html



More information about the users mailing list