comp.lang.ada
 help / color / mirror / Atom feed
From: "Warren W. Gay VE3WWG" <ve3wwg@cogeco.ca>
Subject: Re: Need advice re package organization.
Date: Thu, 31 Jul 2003 12:39:36 -0400
Date: 2003-07-31T12:39:36-04:00	[thread overview]
Message-ID: <7DbWa.1370$qN3.183518@news20.bellglobal.com> (raw)
In-Reply-To: <vigijhb0op0t69@corp.supernews.com>

Randy Brukardt wrote:
> "Warren W. Gay VE3WWG" <ve3wwg@cogeco.ca> wrote in message
> news:clWVa.4191$mv6.741217@news20.bellglobal.com...
> 
>>The problem occurs in the private child package (IMO) because
>>you want to derive new objects from parent tagged records. The
>>danger that develops is that the child package's body code may
>>monkey with things in the parent object that you don't want it
>>to (this is lack of information hiding).
>>
>>However, you can fix the object visibility by making it a non
>>child package (just another package using the first). However,
>>the problem then becomes that you lose access to other types
>>and definitions that are in the other package's private part.
>>
>>So in my mind, there still exists a short-coming OO wise
>>in the visibility rules for objects: it needs a way to
>>mark parts of a tagged object as "off limits" for the child
>>package, which always enjoys full visibility of the parent
>>package's tagged record (object).
> 
> You can do this by deferring the contents of the tagged type to the body:
> 
>      type My_Type_Contents;
>      type My_Type_Contents_Access is access all My_Type_Contents;
>      type My_Type is tagged record
>           Contents : My_Type_Contents_Access;
>      end record;
> 
> Then no child can see the contents. Claw uses this technique in some cases.
> The body contains the full declaration of My_Type_Contents.

That appears to accomplish the end result. However, this
design pays a price in allocating and freeing an additional
[sub]object.

For some designs this would be acceptable, but not where
you have many instances of the object, where the price
of allocate/free is too heavy.

So I think my point still stands: you really cannot "properly"
accomplish what I have set out to do, although you have
illustrated a work-around.

> This technique works best when the tagged type is Controlled (since the vast
> majority of tagged types ought to be controlled, this is not a real
> restriction). Then the Initialize routine can allocate the contents, and the
> Finalize can free it. The only remaining danger would be someone assigning a
> Null into the Contents access, which is a lot less likely than fiddling with
> components.
> 
>                Randy.

Agreed that the risk is lower, but it still exists if you place
the objects (from a library) in the hands of a user.  If you
are supporting that library, this increases risk of servicing
calls that should not be your responsibility.

-- 
Warren W. Gay VE3WWG
http://home.cogeco.ca/~ve3wwg




  reply	other threads:[~2003-07-31 16:39 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-07-26 13:08 Need advice re package organization Bobby D. Bryant
2003-07-26 14:25 ` Robert I. Eachus
2003-07-26 15:27   ` Warren W. Gay VE3WWG
2003-07-26 22:00     ` Robert I. Eachus
2003-07-27 22:01       ` chris
2003-07-28  2:53         ` Robert I. Eachus
2003-07-29  4:52           ` Richard Riehle
2003-07-27 22:02       ` Warren W. Gay VE3WWG
2003-07-28  8:38         ` Dmitry A. Kazakov
2003-07-29 17:18           ` Warren W. Gay VE3WWG
2003-07-30  8:42             ` Dmitry A. Kazakov
2003-07-30 21:00               ` Warren W. Gay VE3WWG
2003-07-30 22:46                 ` Randy Brukardt
2003-07-31 16:39                   ` Warren W. Gay VE3WWG [this message]
2003-07-31 17:31                     ` Randy Brukardt
2003-07-31 21:00                       ` Warren W. Gay VE3WWG
2003-07-31 22:13                     ` Robert I. Eachus
2003-08-01 12:51                       ` Warren W. Gay VE3WWG
2003-07-31  5:57                 ` Matthew Heaney
2003-07-31 16:57                   ` Warren W. Gay VE3WWG
2003-07-31 22:33                     ` Robert I. Eachus
2003-08-01  2:58                       ` Chad R. Meiners
2003-08-01 13:51                         ` Stephen Leake
2003-08-01 22:15                           ` Robert I. Eachus
2003-08-04 13:45                             ` Stephen Leake
2003-08-01 13:01                       ` Warren W. Gay VE3WWG
2003-07-31  9:04                 ` Dmitry A. Kazakov
2003-07-31 16:59                   ` Warren W. Gay VE3WWG
2003-07-31 20:41                     ` Randy Brukardt
2003-07-31 21:15                       ` Warren W. Gay VE3WWG
2003-08-01 20:04                         ` Randy Brukardt
2003-08-01 21:33                           ` Stephen Leake
2003-08-04 19:40                             ` Randy Brukardt
2003-08-04 19:52                               ` Stephen Leake
2003-08-05  3:36                   ` Richard Riehle
2003-08-05  4:03                     ` Hyman Rosen
2003-08-05  7:16                     ` Dmitry A. Kazakov
2003-07-26 17:03 ` Nick Roberts
replies disabled

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