From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,45a9122ddf5fcf5 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Rules for Representation of Subtypes Date: 1996/09/27 Message-ID: #1/1 X-Deja-AN: 185730785 references: organization: The World Public Access UNIX, Brookline, MA newsgroups: comp.lang.ada Date: 1996-09-27T00:00:00+00:00 List-Id: In article , Matthew Heaney wrote: >"If the size of a type of a first named subtype T has been specified by a >length clause, the T'Size yields the specified size, AND THE SIZE OF EVERY >SUBTYPE OF T IS ALSO THIS VALUE [my emphasis]." > >If my interpretation is correct (I'm waiting for an opinion, Bob...), then >this would solve my original problem, which was I'm not sure if I'm the Bob being addressed, but... I think your interpretation is correct. However, in Ada 95, such a rule can't work. Consider: type T is range 0..15; for T'Size use 4; subtype Bigger is T'Base range -15..15; Clearly, Bigger'Size cannot be 4. Also, note that the size of an object can be bigger than the size of its subtype (in both Ada 83 and 95). In other words, specifying the size of an object gives much more exact control, and is desirable in many low-level situations (despite the fact that it is rather verbose). Also, any rule that begins "if the so-and-so attribute is specified..." is suspect, because you don't want the meaning of 'Whatever to depend on whether the user chose it or the compiler chose it. For example, if I print out Foo'Whatever, and find out it's 123, and then I add "for Foo'Whatever use 123;", the meaning of my program shouldn't change. Unfortunately, though, Robert is correct that the new rules cause some problems with porting code from Ada 83 to Ada 95. On the other hand, there were already problems porting between Ada 83 compilers, so I don't know. Sigh. The Java language designers had it much easier -- they simply say that the predefined types are 8, 16, 32, and 64 bits, and if you're running on a 36-bit machine, tough. - Bob