Personal dialects and C++ overloading

Henry Spencer henry at utzoo.uucp
Sat Feb 10 05:11:11 AEST 1990


In article <926.18:17:58 at stealth.acf.nyu.edu> brnstnd at stealth.acf.nyu.edu (Dan Bernstein) writes:
>Overloading saves typing time. It has no other advantages...

Sorry, I can't go along with that.  Saving typing time by itself is not
of massive importance, but shorter programs are.  Other things being
equal, a shorter program is easier to understand, easier to work with,
easier to modify.  The gotcha is in that phrase "other things being equal".
In the case of operator overloading, other things are equal only if the
author has been careful to follow the Law of Least Astonishment when
writing the program.

Operator overloading is a power tool.  One does not give power tools to
children and expect safe use, but for professionals they make work
quicker and easier and thus make harder jobs manageable.  The problem
is that there are too many incompetent amateurs -- calling themselves
programmers -- who will slice off their own fingers, or their successors'
fingers, if given access to power tools.

Unfortunately, it's also true that some power tools are safer than others.
There is room for debate about whether C++'s sharp edges are dangerously
exposed.  Operator overloading is desirable and useful, but placing some
more constraints on it might be desirable.
-- 
SVR4:  every feature you ever |     Henry Spencer at U of Toronto Zoology
wanted, and plenty you didn't.| uunet!attcan!utzoo!henry henry at zoo.toronto.edu



More information about the Comp.lang.c mailing list