]> I don't see the point of this complicated sounding
> "mapper" construct when being able to say "Class X
> implements Y" where Y is a class will do the job
> well.
You're talking compile time for the builder of class X. I'm talking compile time for the *user* of classes X and Y. If you write a perfectly good X class, and Jill writes a perfectly good Y class, and *I* -- a user of both -- would like to be able to treat X as a type of Y, then "implements" won't cut it.
> All I need to do is create a class, MyPoint, that
> "implements B.Point" as we discussed, and takes an
> A.Point instance, and delegates/translates the
> methods of the B.Point interface to the A.Point
> instance.
Given:
A.Point getCoords();
void printCoords(B.point);
Now, with a MyPoint model:
printCoords(new MyPoint(getCoords()));
But with the Haskell model:
printCoords(getCoords());
With the MyPoint technique, interaction between the two kinds of points must be mediated by the creation of an adaptor object. A model that told the runtime that the two were interchangable would allow all code using A.Point to use B.Point's with the same ease as if the originator of B.Point had subclassed A.Point.
Surely that's a non-trivial distinction. If the subtyping, or
IsA, concept has power -- and the whole OO notion fundamentally assumes that it does -- then clearly it is more powerful to establish correct
IsA relationships. Adaptors aren't
IsA -- they're
CanBeMadeToActAsA. And they have the resulting conceptual (and programming) weight. Would you rather create a new MyPoint object for every B.Point object, or provide one set of methods that allow every B.Point to be directly used as an A.Point?
Ken