comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Leake <stephen.a.leake.1@gsfc.nasa.gov>
Subject: Re: Two questions
Date: 12 Mar 2001 12:43:32 -0500
Date: 2001-03-12T17:57:36+00:00	[thread overview]
Message-ID: <uwv9udgsb.fsf@gsfc.nasa.gov> (raw)
In-Reply-To: mailman.984395109.8141.comp.lang.ada@ada.eu.org

Christoph Grein <christoph.grein@eurocopter.de> writes:

> package something_cool is
> 
>     type cool is tagged private;
>     
>     function Create (P: in Some_Parameters) return Cool;    -- gets abstract on
>                                                             -- derivation
>     procedure Create (c : out cool; P: in Some_Parameters); -- does not get
>                                                             -- abstract on
>                                                             -- derivation
>     package constructor is  -- nothing inside will be inherited
> 
>         procedure create (c : out cool; ... ... );
> 
>     end constructor;
> 
> private
>         ...
> 
> end something_cool;
> 
> Thus make your choice. As Randy said, you can end with a bunch of useless 
> constructors with the inherited ones.

A bit more rationale:

If you declare the constructors directly in the main package, they are
"primitive operations of the type", and are thus inherited by derived
types. This is usually not appropriate, since constructors for derived
types will usually take more or different parameters.

Declaring the constructors in a nested package makes them _not_ be
primitive operations, so they are not inherited. 

Another option is to put them in a child package, but that means they
can't take advantage of whatever is declared in the main package body.

-- 
-- Stephe



  reply	other threads:[~2001-03-12 17:43 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-03-12 10:59 Two questions Christoph Grein
2001-03-12 17:43 ` Stephen Leake [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-07-04 22:25 Mark
2002-07-04 22:40 ` Jeffrey Creem
2001-03-09 18:27 chris.danx
2001-03-09 20:22 ` Mark Lundquist
2001-03-09 20:56 ` Randy Brukardt
2001-03-12 15:36 ` John English
2001-03-12 18:11   ` chris.danx
1996-11-09  0:00 tmoran
1996-11-11  0:00 ` Adam Beneschan
1996-11-13  0:00 ` Richard A. O'Keefe
1996-11-07  0:00 Ding-yuan Sheu
1996-11-07  0:00 ` Robert Dewar
1996-11-08  0:00 ` Norman H. Cohen
1996-11-08  0:00 ` Jon S Anthony
1996-11-08  0:00 ` Robert I. Eachus
1996-05-01  0:00 Bernard Banner
1996-05-01  0:00 W. Wesley Groleau (Wes)
1996-05-01  0:00 Ed Seidewitz
1989-04-11 13:32 Piercarlo Grandi
1989-04-14 17:14 ` callen
1989-03-30 11:53 Piercarlo Grandi
1989-04-13  0:46 ` Paul Stachour
1989-03-29  9:16 HansM
1989-03-29 18:35 ` Michael Peirce
1989-03-31 13:10 ` stt
1989-03-31 18:59 ` Scott Simpson
1989-04-03 14:44 ` callen
replies disabled

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