comp.lang.ada
 help / color / mirror / Atom feed
From: Adam Beneschan <adam@irvine.com>
Subject: Re: Extending discriminant types
Date: Thu, 20 Nov 2008 08:11:53 -0800 (PST)
Date: 2008-11-20T08:11:53-08:00	[thread overview]
Message-ID: <4498e535-7c24-4563-bbe8-6533a916a1c2@v39g2000pro.googlegroups.com> (raw)
In-Reply-To: 49254dd7$0$30232$9b4e6d93@newsspool1.arcor-online.net

On Nov 20, 3:45 am, Georg Bauhaus <rm.dash-bauh...@futureapps.de>
wrote:
> Ludovic Brenta schrieb:
>
> > On Nov 20, 9:30 am, christoph.gr...@eurocopter.com wrote:
> >> On 20 Nov., 08:21, a...@anon.org (anon) wrote:
>
> >>> Since, the orginal post suggest that the poster was using GNAT Ada 95
> >>> compiler. Because the poster states that he can compiler the code. So,
> >>> I used Gnat 3.15p using Ada 95 specs.
>
> > One can also try GNAT GPL Edition 2008 or GCC 4.3 (or even 4.4) and
> > pass it the -gnat95 option which is documented in the Secret GNAT
> > User's Guide.
>
> GNAT has -gnat83 as well, but rejects, too, because there are
> neither tagged nor abstract types in Ada 83.
>
> Just out of curiosity, given
>
>    type T is tagged ...;
>    type D is new T with ...;
>    type E is new D with ...;
>
> what would E'Base be?

Type declarations define both "types" and "subtypes".  Only subtypes
have constraints; types don't.  Subtypes and types are different kinds
of entities---a subtype isn't a special case of a type.  So the
declaration of T defines both a type T, and a "first subtype" T.  The
declaration of D defines a derived type D whose parent type is the
*type* T; and it also defines a "first subtype" D of the *type* D..
Similarly for E: it defines a type E whose parent type is D, and a
first subtype E of the type E.  If E'Base were defined the same way
it's defined for scalars, then it would refer to an unconstrained
subtype of the *type* E.  As Bob pointed out, that would be
essentially the same as the "first subtype" E, since there are no
discriminants on that type.  But one could imagine something like

   type U (Disc : Integer) is record ... end record;
   type F is new U(7);
   type G is new F;

The *types* U, F, and G aren't constrained, so if G'Base were allowed,
it would be an unconstrained subtype of G---i.e. Disc could be
anything.  I don't really know why E'Base or G'Base isn't allowed.  As
far as I can tell, it wouldn't cause any semantic problems to allow
it, but it might prevent some useful optimizations in variant record
cases.  But I'm just guessing.


> Assuming that D is privately tagged, would E'Base
> have different effects depending on whether [D's] tag
> is visible or not?  [corrected]

I don't think this question makes sense unless you mistakenly think
that 'Base has something to do with the parent type of a type.  But as
we've pointed out, it doesn't.  By the way, I believe there was a
proposal for a 'Parent attribute or something like that to refer to a
derived type's parent (or its first subtype), but it didn't make it
into the language.

                                 -- Adam





  parent reply	other threads:[~2008-11-20 16:11 UTC|newest]

Thread overview: 68+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-11-15  9:16 Extending discriminant types Stefan Bellon
2008-11-15 18:50 ` Jeffrey R. Carter
2008-11-17 16:30 ` Adam Beneschan
2008-11-18 11:02   ` christoph.grein
2008-11-18 23:24     ` Adam Beneschan
2008-11-19  9:49 ` anon
2008-11-19 10:15   ` christoph.grein
2008-11-19 19:19     ` Georg Bauhaus
2008-11-19 11:38   ` Martin
2008-11-20  7:21   ` anon
2008-11-20  8:30     ` christoph.grein
2008-11-20  8:36       ` Ludovic Brenta
2008-11-20 11:45         ` Georg Bauhaus
2008-11-20 11:46           ` Georg Bauhaus
2008-11-20 23:01             ` anon
2008-11-21 11:54               ` Ludovic Brenta
2008-11-20 14:03           ` Dmitry A. Kazakov
2008-11-20 15:03           ` Robert A Duff
2008-11-20 15:57             ` Stefan Bellon
2008-11-21  0:32               ` Adam Beneschan
2008-11-20 16:11           ` Adam Beneschan [this message]
2008-11-20 22:59       ` anon
2008-11-21  0:29         ` Adam Beneschan
2008-11-21  7:25           ` anon
2008-11-21  9:19             ` Jean-Pierre Rosen
2008-11-21 10:11             ` christoph.grein
2008-11-21 12:00             ` Ludovic Brenta
2008-11-21 22:31               ` anon
2008-11-22  0:18                 ` Stefan Bellon
2008-11-23  4:06                   ` anon
2008-11-23  5:39                     ` Georg Bauhaus
2008-11-23  8:00                       ` anon
2008-11-24 10:08                         ` Georg Bauhaus
2008-11-24 22:16                           ` anon
2008-11-25 10:37                             ` Martin
2008-11-25 11:24                               ` Georg Bauhaus
2008-11-25 20:49                                 ` Jeffrey R. Carter
2008-11-25 21:01                                   ` Adam Beneschan
2008-11-25 22:09                                     ` Georg Bauhaus
2008-11-25 22:33                                       ` Jeffrey R. Carter
2008-11-26  0:58                                         ` Adam Beneschan
2008-11-26  1:45                                           ` Jeffrey R. Carter
2008-11-26  9:31                                             ` Martin
2008-11-26  9:38                                               ` Stefan Bellon
2008-11-26  9:48                                                 ` Martin
2008-11-26 10:16                                                   ` Stefan Bellon
2008-11-26 11:05                                                     ` Ludovic Brenta
2008-11-26 11:33                                                       ` Stefan Bellon
2008-11-26 15:49                                                       ` Adam Beneschan
2008-11-26 16:15                                                         ` Ludovic Brenta
2008-11-26 11:10                                                 ` Niklas Holsti
2008-11-23  8:48                     ` Compiler quality (was: Extending discriminant types) Ludovic Brenta
2008-11-24 23:33                       ` anon
2008-11-25  6:54                         ` christoph.grein
2008-11-25 10:01                         ` Ludovic Brenta
2008-11-26 23:34                           ` anon
2008-11-27 10:24                             ` Compiler quality Georg Bauhaus
2008-11-27 14:46                               ` Ludovic Brenta
2008-11-28  9:13                                 ` Martin
2008-11-28 10:28                                   ` Georg Bauhaus
2008-12-02  3:51                                     ` Randy Brukardt
2008-11-22 13:10                 ` Extending discriminant types Gautier
2008-11-24  8:24                 ` christoph.grein
2008-11-21  6:11         ` christoph.grein
2008-11-21 21:12           ` Jeffrey R. Carter
2008-11-22 16:41             ` sjw
2008-11-21 11:44         ` Martin
2008-11-20  9:55     ` Martin
replies disabled

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