[mercury-users] this appears to be a mixin
Ralph Becket
rbeck at microsoft.com
Tue Jul 10 19:23:39 AEST 2001
> From: Terrence Brannon [mailto:tmbranno at oracle.com]
> Sent: 10 July 2001 05:28
>
> 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.
Two (possibly three) books are contemplated: a tutorial, something
for L/FP experts, and possibly a "Mercury for the Real World" type
affair. Working examples should be de rigeur.
> 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).
Having searched around on the web for a definition, it's still not
clear to me exactly what constitutes a mixin class. As far as I
can work out, mixin classes are pretty much the same thing as
Java/C# interfaces - that is, something inheriting from a mixin
class must provide its own implementations for the method signatures
specified in the mixin class. On this basis, type classes are very
similar to interfaces/mixin classes since they do not provide
implementation inheritance.
- Ralph
--------------------------------------------------------------------------
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