typedef laxity

Larry Campbell campbell at maynard.BSW.COM
Tue Apr 12 03:33:43 AEST 1988


In article <542 at picuxa.UUCP> gp at picuxa.UUCP (Greg Pasquariello X1190) writes:
<>In article <1070 at maynard.BSW.COM> campbell at maynard.BSW.COM (Larry Campbell) writes:
<>>It seems to me someone should complain about this code:
<>>
<>>	typedef int TEMPERATURE;
<>>	typedef int PRESSURE;
<>>
<>>	TEMPERATURE tx, ty;
<>>	PRESSURE px, py;
<>>
<>>	ty = py;		/* type clash */
<>>
<>>But none of the compilers I've tested (pcc, VAX-11 C, Wang VS C, Turbo C)
<>>complain about it, and, even worse, _lint_ doesn't complain!
<>
<>
<>The compiler does not complain about this, because it is not really a type
<>clash.  Typedef simply creates synonyms for a type.  The compiler treats both
<>"new types" the same as int.
<>
<>Greg Pasquariello
<>ihnp4!picuxa!gp

Well, I have gotten several mail messages and seen several followups all
saying the same thing:  "That's just the way it works."  As opposed to
saying "It works this way because of <insert good idea>".  I still haven't
heard anyone argue that mixing types (all right, mixing type NAMES) like this
is a good programming practice, and haven't heard any arguments as to why
it's a _good thing_ that lint doesn't complain.

I _know_ how it works.  I am arguing that how it works is a _bad thing_.
I would like lint, at least, to complain.  Can anyone convince me that
it shouldn't?  (For example, show me a code fragment where it is both
reasonable and readable to mix type names as in the above example.)
-- 
Larry Campbell                                The Boston Software Works, Inc.
Internet: campbell at maynard.bsw.com          120 Fulton Street, Boston MA 02109
uucp: {husc6,mirror,think}!maynard!campbell         +1 617 367 6846



More information about the Comp.lang.c mailing list