[mercury-users] Pre- and Post- conditions

Marko Schuetz marko at king.ki.informatik.uni-frankfurt.de
Wed Oct 7 19:04:34 AEST 1998


Patrick,

I would prefer the syntax of the first example

>>>>> "Patrick" == Patrick KREPS <pkreps at cs.mu.OZ.AU> writes:

[...]
Patrick> 1st WAY :
Patrick> ----------------------------------------------------------------------------

Patrick> :- pred append6(list(T),list(T),list(T)).
Patrick> :- mode append6(in,in,out).
Patrick> :- pre append6(A::in,B::in,_::out) is preapp6(A,B).
Patrick> :- post append6...

over

[...]
Patrick> 2nd WAY :
Patrick> ----------------------------------------------------------------------------

Patrick> :- pred append6(list(T),list(T),list(T)).
Patrick> :- mode append6(in,in,out).
Patrick> :- pre (append6(A::in,B::in,_::out),
Patrick> 	"list__length(A,X),
Patrick> 	list__length(A,X),
Patrick> 	Z=X+Y,
Z> =6"
Patrick> 	).
Patrick> :- post...

But could you not use the syntax of the first example to write
something like 

:- pre append6(A::in,B::in,_::out) is 
	list__length(A,X),
	list__length(B,Y),
	Z=X+Y,
        Z> =6.


allowing a program fragment after the 'is'?

Marko



More information about the users mailing list