Typedef names vs. new types.

Karl Heuer karl at haddock.ima.isc.com
Sat Oct 29 04:45:08 AEST 1988


In article <8755 at smoke.BRL.MIL> gwyn at smoke.BRL.MIL (Doug Gwyn) writes:
>In article <10006 at haddock.ima.isc.com> karl at haddock (Karl Heuer) writes:
>>Let's enhance the syntax of declarations to include a dimension-specifier...
>
>Unfortunately this is too simplistic.  For example, there are several
>ways to combine the Cartesian-projected elements of a tensor to produce
>a quantity having different dimension, but the resulting dimension is
>not ascertainable from a syntactic analysis of the combination.  Also,
>units that people usually consider different turn out to be the same
>when one has a sufficiently powerful physical theory.

I think my proposal could handle the latter situation; if you want to freely
mix (say) distance and time, you can declare them to be the same unit, while
if you prefer to treat them as independent, you can explicitly multiply by
speed_of_light (which would have value 1, so the compiler can optimize it out,
but dimensions of velocity, so CDA would sanction it).

If the tensor problem can't be resolved at compile-time, then of course CDA
can't do anything about it.  (But it can still pass it through with no
warnings; CDA includes C as a trivial case.)  I could live with that; it's no
worse than what we have now.  Similarly, I described the language as being
able to handle dimensions that were a composite of additive and multiplicative
units, but aside from the temperature-conversion example I can't think of any
applications for it, so I'd probably drop that feature (provided it's still
possible to get array-by-enum working).

Karl W. Z. Heuer (ima!haddock!karl or karl at haddock.isc.com), The Walking Lint



More information about the Comp.std.c mailing list