comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@ni.net (Matthew Heaney)
Subject: Re: Ada 83 - Rep clause inside private area question
Date: 1997/04/20
Date: 1997-04-20T00:00:00+00:00	[thread overview]
Message-ID: <mheaney-ya023680002004971026380001@news.ni.net> (raw)
In-Reply-To: 33575FD0.41C67EA6@hercii.mar.lmco.com


In article <33575FD0.41C67EA6@hercii.mar.lmco.com>, "Angelo A. Keene"
<akeene@hercii.mar.lmco.com> 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
<mailto:matthew_heaney@acm.org>
(818) 985-1271




  reply	other threads:[~1997-04-20  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-18  0:00 Ada 83 - Rep clause inside private area question Angelo A. Keene
1997-04-20  0:00 ` Matthew Heaney [this message]
1997-04-20  0:00   ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox