[mercury-users] this appears to be a mixin

Terrence Brannon tmbranno at oracle.com
Tue Jul 10 14:28:01 AEST 2001


I'm not sure what sort of angle the Mercury book will be taking in
comparison to the Language Reference Manual, but I hope that it is
full of completely working pragmatic examples.

Also, I think the book will be hard to write because at any point when
discussing Mercury you must be conscious of the (at least) 3 types of
audiences that may be reading it: those from the imperative,
object-oriented, or functional perspectives. 

On top of that you may be dealing with beginners, intermediates or
advanced in each of those arenas.

But anyway, my feeling is that the code below was not described as a
mixin, when it does in fact appear to be so.

:- pred distance(P1, P2, float) <= (point(P1), point(P2)).
:- mode distance(in, in, out) is det.

distance(A, B, Distance) :-
        coords(A, Xa, Ya),
        coords(B, Xb, Yb),
        XDist = Xa - Xb,
        YDist = Ya - Yb,
        Distance = sqrt(XDist*XDist + YDist*YDist).


--------------------------------------------------------------------------
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