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,9593355bec84b137 X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: Ada 83 - Rep clause inside private area question Date: 1997/04/20 Message-ID: #1/1 X-Deja-AN: 236170307 References: <33575FD0.41C67EA6@hercii.mar.lmco.com> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-04-20T00:00:00+00:00 List-Id: In article <33575FD0.41C67EA6@hercii.mar.lmco.com>, "Angelo A. Keene" wrote: >If I have two Ada83 packages, defined as follows -- what are the >differences between the two, if any? Would a user of this package >not have access to the 'SIZE function now? > >package Test_Types_One is [snip] >package Test_Types_Two is [snip] >While building a short test package, I accidentally ended up with a >package in the second form, which compiles successfully -- but after >looking at it, I started thinking about the implications of what I >wrote -- looking at my available references, I can't determine >if the second form would have any useful meaning or not. There's no difference between the two packages. And you can always take the 'Size of something, even a private type. There's a debate about this very issue among Ada programmers. Some like to push the rep specs off into the private region, arguing that a client shouldn't really care. Others (myself among them) believe that the rep spec should be in the public part, because the representation is an essential characteristic of the type. You only do rep specs when you're doing some kind of I/O - either to another language or to an external hardware device. Since this is a low-level thing, you don't need to bother with any more abstraction by putting the rep spec in the private part. The time when it does matter is when you declare an object of the type in the same package as the type. Ada 83 calls this a "forcing occurance" and Ada 95 a "freezing point." At the point of declaration of the object, the representation must be known, so you'd have to have already used the rep spec. Matt -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271