From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 13 Feb 93 19:18:10 GMT From: agate!spool.mu.edu!hri.com!noc.near.net!inmet!spock!stt@ucbvax.Berkeley.E DU (Tucker Taft) Subject: Re: What's the difference between... Message-ID: <1993Feb13.191810.4452@inmet.camb.inmet.com> List-Id: In article <64238@mimsy.umd.edu> alex@cs.umd.edu (Alex Blakemore) writes: [good stuff deleted] > . . . > the compiler must use the same representation for all objects of > a type (irregardless of any subtypes) in this case, a placement > must take as many bits as any other integer, so the compiler > will likely use 4 bytes (say) and not 1 byte for each placement object. This is not true. In the absence of a size clause, objects of a given subtype may be of any size sufficient to hold every possible value of the subtype. Actually, objects can be even smaller (in fact, non-existent) if an optimizer knows all of the uses of the object, and knows the actual range of values ever stored into the object. It is true that some compilers follow the rule you state, but others do not (and still validate, for what that's worth ;-). With this latter group of compilers, objects of the subtype could also be just one byte. Remember that all numeric types use pass by copy for parameter passing, so the actual representation of a numeric object need not be known outside its lexical scope, and need not be the same as other objects of the same numeric type. The important point (which you and others have already made) has to do with static semantics, not representation. Operands of distinct types cannot be mistakenly combined using the predefined operators or assignment. Explicit type conversion is required (of course that's a bit annoying for multiplication -- we never did get around to putting full support for "units" into Ada). By contrast, operands which differ only in subtype are freely combinable with the predefined operators and assignment (subject to run-time constraint checks on assignment). >Alex Blakemore alex@cs.umd.edu NeXT mail accepted S. Tucker Taft stt@inmet.com Intermetrics, Inc. Cambridge, MA 02138