typedef laxity

Jay Maynard jay at splut.UUCP
Sat Apr 16 23:18:36 AEST 1988


In article <3415 at haddock.ISC.COM> karl at haddock.ima.isc.com (Karl Heuer) writes:
>Okay, let's pretend we have such strictness.
>  typedef int foo_t;
>  typedef int bar_t;
>  foo_t f1, f2;
>  bar_t b1;
>  int   i;
>
>Now, which of the following expressions should be legal, and what should be
>their types?
>  -f1         f1 + 1      f1 - f2     f1 * 5      f1 / f2
>  f1 + b1     f1 * b1     f1 = i      i = f1      f1 = b1

My (non-C-guru, and therefore solely intuitive) take at this is that
typedef'd stuff should be freely intermixable with objects of the same
(typedef'd) type and the underlying type, but not other typedef'd types.
(As this would probably break _mountains_ of existing code, I, like
Larry Cipriani, suggest this should be a lint function...one that could
be turned off.) Assignments would not do automatic conversion between
typedef'd types, but could between the typedef'd type (is there a word
for that?? :-) and the underlying type.

This would make all the above except f1+b1, f1*b1, and f1=b1 legal.

>I'm not saying that dimensional analysis shouldn't be done, just that it's not
>trivial to define the rules.  In fact I have a partially-written essay on
>this, which I might post someday...

Please enlighten me as to the complications, as the above _seems_ too
easy...


-- 
Jay Maynard, EMT-P, K5ZC...>splut!< | GEnie: JAYMAYNARD  CI$: 71036,1603
uucp: {uunet!nuchat,hoptoad!academ!uhnix1,{ihnp4,bellcore}!tness1}!splut!jay
Never ascribe to malice that which can adequately be explained by stupidity.
Pledge #29: Vote for Kent Paul Dolan and the Birthright Party in '88!



More information about the Comp.lang.c mailing list