At 12:29 pm +1200 20/5/99, Brian Boutel wrote:
> In response to a question about ad hoc overloading:
>
> On Thursday, May 20, 1999 9:10 AM, Nigel Perry [SMTP:[EMAIL PROTECTED]] wrote:
> >
> > So to answer the question: it can be done, by a simple existance proof :-)
>
> Of course it *can* be done, but *should* it be done?
Well the "of course" wouldn't be agreed by all - as some see the theoretical
NP-complete problem as too much to deal with, anyway...
> Uncontrolled overloading means that when you see a function application you can't
> immediately see what function is being applied - you see its name but not its
>semantics, because
> there may be many different functions with the same name.
>
> Obfuscating the program source in this way presents a risk of error, and is bad
>language engineering.
>
> What would be gained by allowing ad hoc overloading? If operations on different
>types have similar meaning
> there is a case for defining a new class. If you have existing different functions
>with similar names you can
> qualify them to avoid the ambiguity. When else would you want this feature?
Overloading went into Hope+ as it was requested by a major user, sounds like a good
reason ;-) It also gave the opportunity to write a paper or two... ;-) Oh, and it was
a fun challenge at the time :-)
Seriously I both agree and disagree with Brian. It is very easy to abuse overloading,
and its use should be discouraged if to do so obscures the programs meaning. On the
other hand when there is an obvious meaning it is a great convenience, and not all
such cases can be handled by a Haskell-class-like mechanism. Of course the
Haskell-class mechanism can be just as easily used to obscure the semantics of a
program - I don't think we've found a way yet of forcing people to write clear
programs (as I'm marking right now I wish there was! :-)) Having overloading can
sometimes even make a program easier to read as it can avoid the production of
similar-but-different names for similar operations on completely unrelated types.
Back to that marking...
Cheers,
Nigel