[m-dev.] diff: higher_order.m termination fix

Simon TAYLOR stayl at students.cs.mu.oz.au
Sun Jun 15 22:11:32 AEST 1997


> > compiler/higher_order.m
> > 	Don't create specialised versions of specialised versions,
> > 	since for some fairly contrived examples of building up 
> > 	lambda expressions recursively a ridiculously large number 
> > 	of versions can be created.
> 
> Can you give an example?

:- module h.
:- interface.

:- pred h(int, pred(int, int), int) is det.
:- mode h(in, pred(in, out) is det, out) is det.

:- pred p(int::out) is det.

:- pred q(int::in, int::out) is det.

:- implementation.

:- import_module int.

h(A, X, Y) :-
	( A > 0 ->
		X1 = lambda([Y1::in, Y2::out] is det, (
			call(X, Y1, Y2)
		)),
		A1 is A - 1,
		h(A1, X1, Y)
	;
		call(X, 0, Y)
	).

p(Y) :-
	h(1, q, Y).

q(X, Y) :-
	Y is X + 1.



More information about the developers mailing list