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,72340e997bfd5289 X-Google-Attributes: gid103376,public From: "Matthew Heaney" Subject: Re: array size Date: 1999/12/11 Message-ID: <3852887a_4@news1.prserv.net>#1/1 X-Deja-AN: 559421286 Content-transfer-encoding: 7bit References: <101219991605504828%hopperj@macconnect.com> <3851d15b_1@news1.prserv.net> <82to3s$ng7$1@nnrp1.deja.com> Content-Type: text/plain; charset="US-ASCII" X-Complaints-To: abuse@prserv.net X-Trace: 11 Dec 1999 17:23:06 GMT, 129.37.62.58 Organization: Global Network Services - Remote Access Mail & News Services Mime-version: 1.0 Newsgroups: comp.lang.ada Date: 1999-12-11T00:00:00+00:00 List-Id: In article <82to3s$ng7$1@nnrp1.deja.com> , Robert Dewar wrote: >> Always do this for composite types: >> >> Preset_Array_Type_Size : constant := 6 * Frequency_Type'Size; >> for Preset_Array_Type'Size use Preset_Array_Type_Size; > > > This is incomprehensible advice, these are obviously equivalent. > Both will of course be illegal if Frequency_Type'Size is not > static ... Matthew what are you trying to say here? You have to look at my whole example. The reason you use the locution above, is so that you can refer to the static constant in other type declarations. (The constant to specify the value of T'Size is static, yet the expression T'Size is nonstatic, because T is a nonstatic type. I don't understand the rationale for such an odd language feature.) In this particular example, Frequency_Type'Size is static (because it's a static scalar type). So you can use it as the value of a (static) named number; here, the size of the Preset_Array_Type. You use the static named number when you declare an array (or record) type that contains Preset_Array_Type as a component: type T is array (1 .. 10) of Preset_Array_Type; for T'Component_Size use Preset_Array_Type_Size; for T'Size use 10 * Preset_Array_Type_Size; Note that we refer to the static constant, not to the size attribute directly. In other words, this ... type T is array (1 .. 10) of Preset_Array_Type; for T'Component_Size use Preset_Array_Type'Size; for T'Size use 10 * Preset_Array_Type'Size; ... won't compile. Don't ask me why the language was designed this way, because it makes no sense to me! RM83 4.9 was too conservative wrt what's officially static, and RM95 4.9 improved things, but RM95 4.9 is still too conservative. There's no obvious reason I have to use the locution above (always declare a static constant for composite type sizes, and refer to the constant instead of T'Size). What's "incomprehensible" is the rationale for not allowing some composite types to be officially static. -- I see no good reasons why the views given in this volume should shock the religious feelings of anyone. Charles Darwin, The Origin of Species