[comp.software-eng] Ada language & overloading.

mjl@cs.rit.edu (03/04/90)

In article <8219@hubcap.clemson.edu> billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu writes:
>From peter@ficc.uu.net (Peter da Silva):
>> Would you care to address the confusing and dangerous deficiencies in
>> the ADA language: operator overloading ...
>
>   The implementation of the operator to be used is completely 
>   determined by the type(s) of the parameters involved and by 
>   the visibility rules.  Where do you see problems?

The implementation of ``break'' is completely determined by the
nesting arrangement of loop and switch constructs in C.  Where do you
see problems? :-)

Actually, though I use C quite frequently, and I've found it to be a
useful, reliable notation, I happen to agree with most of what Bill
says about ``break'', but similar arguments can be made about
overloading.

The problem with overloading is that it provides ad-hoc polymorphism:
it's pure syntactic sugar, with no semantic relationship (other than
convention) among the various uses of same symbol.  Thus if you decide
to make "+" mean something radically different from addition, you set
up strong cognitive dissonance for the poor programmers (oops! software
engineers!) trying to use your package.  While you may argue that no
one would do this, my experience is that a non-transitive relation
"sorta-like" soon takes hold:

	1. The foobie operation on widgets is sorta-like addition,
	   so let's overload '+'.

	2. The dingle operation on grodgets is sorta-like '+' on
	   widgets, so let's overload '+'.

However, it's often the case that the dingle operation on grodgets isn't
sorta-like integer addition, and the semantics of '+' start to diverge.

If you want to see how polymorphism can be both controlled and useful,
look at ML.

SIDE NOTE:

In his self-appointed role as apologist for Ada and defender of the
Faith, Bill Wolfe has repeatedly demonstrated his inability to
recognize, much less acknowledge, that any facility is Ada is less than
perfect, or that any facility in a competing language might have
something to offer.  This, of course, is a good operational definition
of zealotry.  Annoying as it is, there's a pleasing symmetry in the
fact that one can be as irrational and fanatic about Ada as C, Pascal,
FORTRAN, COBOL, Modula, LISP, Prolog, ...

The tendency to mono-lingualism in software development is as
inhibiting and confining as it is in natural languages; the only hope
for a "cure" is a good, broad course in programming language concepts.
I hope Bill and adherents to other One True Languages take such a
course and gain some perspective and balance.

END NOTE

Mike Lutz
Rochester Institute of Technology
Mike Lutz	Rochester Institute of Technology, Rochester NY
UUCP:		{rutgers,cornell}!rochester!rit!mjl
INTERNET:	mjl@csrit.edu