At 13:29 +0200 1999/05/20, Jan de Wit wrote:
>I think ad-hoc overloading should be restricted to functions with the same
>number of arguments, otherwise translating Java's
>int sum(int a,int b) { /* obvious code here */ }
>int sum(int a,int b,int c) { /* ditto */ }
>into overloaded Haskell would give a fairly ambiguous type for sum 3 4
>(Int or Int -> Int)
>Especially when you have other stuff in your program such as
>apply :: Int -> a -> a
>apply (n::Int) _ = error "Can't apply integers!"
>apply :: (a -> b) -> a -> b
>apply f x = f x
>
>What would be the value of apply (sum 3 4) 5?

I think that name overloading in a language should be resolve by localizing
the names to classes. If say one wants "+" be applicable to the types
    (Int, Int)
    (Int, Float)
    (Float, Int)
    (Float, Float)
then one can put the "+" applicable to (Int, Int) in the class Int, and the
"+" applicable to the other argument types in the class Float as a single
function.

Then these names are exported by some mechanism, perhaps corresponding to
the "using" directive in C++. If a name conflict occurs, one can type +_Int
or +_Float, indicating which copy is intended.

  Hans Aberg
                  * Email: Hans Aberg <mailto:[EMAIL PROTECTED]>
                  * Home Page: <http://www.matematik.su.se/~haberg/>
                  * AMS member listing: <http://www.ams.org/cml/>




Reply via email to