On 19-May-1999, Lennart Augustsson <[EMAIL PROTECTED]> wrote:
> Kevin Atkinson wrote:
>
> > I was wondering what the generally felling to allowing true ad-hoc
> > overloading like it is done in C++ in Java but more powerful because
> > functions can also be overloaded by the return value.
>
> Yes, I've given this thought. And so have many others, I'm sure.
> First, should it be done as in Java, where only the arguments are used
> to resolve the overloading. Or should it be done as in Ada (can't
> remember what C++ does right now) where both the arguments
> and the expected result type are used.
It should be done as in Ada, IMHO.
> I like the Java approach because it is simple to understand and
> only requires buttom-up processing.
If you're doing type inference then you already need more than just
a single bottom-up pass. So this advantage of the Java approach
is already lost in Haskell. In a language which already supports type
inference, handling overloading on return types doesn't require any
more complexity in the type inference algorithm than that which is
required to handle overloading on argument types.
Another good reason for allowing ad-hoc overloading on return types is
for consistency with Haskell's type class system, which allows
type-class overloading on return types.
--
Fergus Henderson <[EMAIL PROTECTED]> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger [EMAIL PROTECTED] | -- the last words of T. S. Garp.