Path: utzoo!utgpu!water!watmath!clyde!att-cb!osu-cis!tut.cis.ohio-state.edu!mailrus!rutgers!bellcore!tness7!tness1!splut!jay From: jay@splut.UUCP (Jay Maynard) Newsgroups: comp.lang.c Subject: Re: typedef laxity Summary: intuition from a C non-guru Message-ID: <484@splut.UUCP> Date: 16 Apr 88 13:18:36 GMT References: <1070@maynard.BSW.COM> <542@picuxa.UUCP> <1071@maynard.BSW.COM> <3415@haddock.ISC.COM> Reply-To: jay@splut.UUCP (Jay Maynard) Organization: Confederate Microsystems, League City, TX Lines: 37 In article <3415@haddock.ISC.COM> karl@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!