comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <matthew_heaney@acm.org>
Subject: Re: tagged types extensions - language design question
Date: 2000/01/29
Date: 2000-01-29T00:00:00+00:00	[thread overview]
Message-ID: <zvsk4.3465$Sa2.129821@newsread2.prod.itd.earthlink.net> (raw)
In-Reply-To: s94522bcq0s54@corp.supernews.com

In article <s94522bcq0s54@corp.supernews.com> , "Vladimir Olensky" 
<vladimir_olensky@yahoo.com> wrote:

>>It's hard to make hard and fast rules here, but in general, you should
>>use a package hierarchy to declare a type hierarchy.  (This would be
>>required in other OOP languages as well.)
>
>
> This is what I am doing in reality but additional intermediate packages
> for derived types with public attributes break naming scheme in this chain.

The intermediate type (the one with the public attributes) need not
break the naming scheme.

You can declare the intermediate type in its own package, and then types
that derive from that one simply 'with' the package, instead of becoming
a child.

Here's some code:

package P is

   type T is tagged private;

private

   type T is tagged record
      I : Integer;
   end record;

end P;


package P.C is

   type NT is abstract new T with record
      F : Float;
   end record;

end P.C;


with P.C;
package P.C1 is

   type NT1 is new P.C.NT with private;

private

   type NT1 is new P.C.NT with record
      B : Boolean;
   end record;

end P.C1;


with P.C;
package P.C2 is

   type NT2 is new P.C.NT with private;

private

   type NT2 is new P.C.NT with record
     Another_Float : Long_Float;
   end record;

end P.C2;


with P.C1;
with P.C2;
procedure Test_Public is

   O1 : P.C1.NT1;
   O2 : P.C2.NT2;

begin

   O1.F := 2.5;
   O2.F := 3.4;

end Test_Public;


This is an example of a type hierarchy *not* following the package
hierarchy.  Types NT1 and NT2 both derive from intermediate type P.C.NT,
but they are declared in child packages of P, not P.C.

As they say, the exception proves the rule.

Does this meet your needs?


--
Philosophy may be ignored but not escaped; and those who most ignore
least escape.

David Hawkins






  reply	other threads:[~2000-01-29  0:00 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-27  0:00 tagged types extensions - language design question Vladimir Olensky
2000-01-27  0:00 ` Matthew Heaney
2000-01-27  0:00   ` Charles Hixson
2000-01-28  0:00   ` Vladimir Olensky
2000-01-28  0:00     ` Matthew Heaney
2000-01-28  0:00       ` Charles Hixson
2000-01-28  0:00         ` Matthew Heaney
2000-02-01  0:00           ` Charles Hixson
2000-02-01  0:00             ` Matthew Heaney
2000-01-29  0:00       ` Vladimir Olensky
2000-01-29  0:00         ` Matthew Heaney [this message]
2000-01-29  0:00         ` Matthew Heaney
2000-01-31  0:00           ` Vladimir Olensky
2000-01-31  0:00             ` Matthew Heaney
2000-01-31  0:00               ` Vladimir Olensky
2000-01-27  0:00 ` Laurent Guerby
2000-01-28  0:00   ` Vladimir Olensky
2000-01-28  0:00     ` Andy
2000-01-28  0:00       ` Vladimir Olensky
2000-01-29  0:00         ` Andy
2000-01-31  0:00           ` Vladimir Olensky
2000-01-27  0:00 ` Fraser
2000-01-28  0:00 ` Tucker Taft
2000-01-31  0:00   ` Vladimir Olensky
2000-02-01  0:00   ` Charles Hixson
2000-02-01  0:00     ` Matthew Heaney
2000-02-01  0:00       ` Brian Rogoff
2000-02-03  0:00         ` scripting/extension language for Ada (was : Re: tagged types extensions) root
2000-02-03  0:00           ` Brian Rogoff
2000-02-04  0:00             ` Ray Blaak
2000-02-04  0:00               ` Stanley R. Allen
2000-02-04  0:00                 ` Samuel T. Harris
2000-02-05  0:00                   ` Lionel Draghi
2000-02-05  0:00                     ` Samuel T. Harris
2000-02-06  0:00                       ` Bryce Bardin
2000-02-08  0:00                         ` Samuel T. Harris
2000-02-06  0:00                       ` Lionel Draghi
2000-02-05  0:00                 ` Ray Blaak
2000-02-05  0:00                 ` Lionel Draghi
2000-02-04  0:00               ` Robert A Duff
2000-02-05  0:00                 ` Ehud Lamm
2000-02-05  0:00                 ` blaak
2000-02-05  0:00                   ` Brian Rogoff
2000-02-09  0:00                   ` Robert A Duff
2000-02-09  0:00                     ` Ted Dennison
2000-02-10  0:00                       ` Samuel T. Harris
2000-02-10  0:00                 ` Pascal Martin
2000-02-10  0:00                   ` Ray Blaak
2000-02-11  0:00                     ` scripting/extension language for Ada (we have an opportunity here) Tarjei T. Jensen
2000-02-11  0:00                       ` Robert I. Eachus
2000-02-12  0:00                         ` blaak
2000-02-12  0:00                         ` Samuel T. Harris
2000-02-12  0:00                         ` Pascal Martin
2000-02-13  0:00                           ` Robert I. Eachus
2000-02-16  0:00                             ` scripting/extension ... [off topic] Nick Roberts
2000-02-16  0:00                               ` Ray Blaak
2000-02-12  0:00                         ` scripting/extension language for Ada (we have an opportunity here) Tarjei Tj�stheim Jensen
2000-02-12  0:00                           ` root
2000-02-12  0:00                           ` Samuel T. Harris
2000-02-14  0:00                             ` Robert A Duff
2000-02-15  0:00                               ` Samuel T. Harris
2000-02-16  0:00                                 ` Robert A Duff
2000-02-16  0:00                                   ` Samuel T. Harris
2000-02-16  0:00                                     ` Robert A Duff
2000-02-17  0:00                                       ` Samuel T. Harris
2000-02-11  0:00                     ` scripting/extension language for Ada (was : Re: tagged types extensions) David Starner
2000-02-12  0:00                       ` blaak
2000-02-15  0:00                         ` Brian Rogoff
2000-02-12  0:00                       ` Pascal Martin
2000-02-14  0:00                     ` Robert A Duff
2000-02-05  0:00             ` scripting/extension language for Ada (was : Re: tagged typesextensions) Lionel Draghi
2000-02-05  0:00           ` scripting/extension language for Ada (was : Re: tagged types extensions) Ehud Lamm
2000-02-06  0:00             ` Lionel Draghi
2000-02-06  0:00               ` Ehud Lamm
2000-02-06  0:00               ` scripting/extension language for Ada Terry Westley
2000-02-09  0:00               ` scripting/extension language for Ada (was : Re: tagged types extensions) Robert A Duff
2000-01-31  0:00 ` tagged types extensions - language design question Mark Lundquist
2000-02-01  0:00   ` Ehud Lamm
2000-02-01  0:00   ` Simon Wright
2000-02-01  0:00   ` Vladimir Olensky
replies disabled

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