by chancho · 17y ago · 0 comments
On the larger issue of free-for-all overloading I mostly agree with you: it causes unnecessary confusion. I'm comfortable with it and like it in my own personal code but I could see how you would want to avoid it in larger projects.
data Foo a = Blah a | Bar (Foo [a])
and you'll have no trouble making a function "showFoo :: Show a => Foo a -> String" using straightforward programming. If you try to do that in C++ you'll get infinite template recursion.Also, C++ templates don't restrict you to match the right type signatures, the way Haskell typeclasses do.
But other than that, they are pretty much the same kind of thing and are used in the same way.
---------
Edit: nm I see what you did there with the Foo a = ... | Blah (Foo [a]). That would probably break C++.