comp.lang.ada
 help / color / mirror / Atom feed
From: bbalfour@std.caci.com (Brad Balfour)
Subject: Re: How to overload assignment in Ada 95?
Date: 1996/12/10
Date: 1996-12-10T00:00:00+00:00	[thread overview]
Message-ID: <bbalfour-1012961302000001@stmac0088.std.caci.com> (raw)
In-Reply-To: mheaney-ya023280000912962054110001@news.ni.net


In article <mheaney-ya023280000912962054110001@news.ni.net>,
mheaney@ni.net (Matthew Heaney) wrote:
[snip]
>Does anyone have a rule of thumb for when a controlled type should publicly
>derive from type Ada.Finalization.Controlled?
[snip]
>In the former case, clients of the Unbounded_Stack have direct visibility
>to the operations Initialize, Finalize, and Adjust.  When is this a good
>thing?  A bad thing?

This exact question was dealt with in the next two articles in the Tips &
Tidbits series (see <http://www.acm.org/~bbalfour/tips_and_tidbits.html>):

 Number 2: Expressing Design Inheritance Relationships in Ada 95,
   published in Ada Letters, Vol. XV No. 3, May/June, 1995. 
         <http://www.acm.org/~bbalfour/tips_no_2.html>
 Number 3: Inheritance and Child Library Units, published in Ada
      Letters, Vol. XV No. 4, July/August, 1995.
         <http://www.acm.org/~bbalfour/tips_no_3.html>

There are actually two separate issues/trade-offs:
1) A visible extension vs a private extension of the parent and
2) Derivation in the visible part vs. a private type and derivation
    in the private part.
The above two articles discuss when each technique is appropriate.

However, one conclusion has become fairly obvious in retrospect. If
overridings of Adjust, Finalize and Initialize are provided in the visible
part, then it is possible for clients to call them directly -- a situation
that is *not* desireable. Therefore, I now recommended that the overriding
declarations appear in the private part. However, moving the overridings
to the private part opens the (small) possiblity that the type declaration
becomes frozen prior to these declarations. If this were to happen, the
compiler would issue an error message. At that point, the developer can
then modify the code to move the declarations prior to the freezing point.

>--------------------------------------------------------------------
>Matthew Heaney
>Software Development Consultant
>mheaney@ni.net
>(818) 985-1271

-- 
Brad Balfour                            SIGAda WWW Server
CACI, Inc.                                http://www.acm.org/sigada/
(703) 277-6767                          and also try:
bbalfour@std.caci.com                     http://www.adahome.com/
address: 3930 Pender Drive * Fairfax, VA 22030
   "...they even have have rules on exceptions" -- Dewar and Schonberg




  reply	other threads:[~1996-12-10  0:00 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-12-06  0:00 How to overload assignment in Ada 95? Christopher D Carothers
1996-12-07  0:00 ` Robert Dewar
1996-12-09  0:00 ` Brad Balfour
1996-12-09  0:00   ` Matthew Heaney
1996-12-10  0:00     ` Brad Balfour [this message]
1996-12-10  0:00       ` Larry Kilgallen
1996-12-11  0:00         ` Brad Balfour
1996-12-11  0:00           ` Larry Kilgallen
     [not found]       ` <01bbe6dc$6feb3620$829d6482@joy.ericsson.se>
1996-12-11  0:00         ` Norman H. Cohen
1996-12-11  0:00         ` Brad Balfour
1996-12-10  0:00     ` Robert A Duff
1996-12-10  0:00 ` Jon S Anthony
1996-12-11  0:00   ` Brad Balfour
1996-12-13  0:00     ` Robert A Duff
replies disabled

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