comp.lang.ada
 help / color / mirror / Atom feed
From: eachus@spectre.mitre.org (Robert I. Eachus)
Subject: Re: Question about base types
Date: 1997/01/28
Date: 1997-01-28T00:00:00+00:00	[thread overview]
Message-ID: <EACHUS.97Jan27211816@spectre.mitre.org> (raw)
In-Reply-To: mheaney-ya023280002601971414080001@news.ni.net


In article <mheaney-ya023280002601971414080001@news.ni.net> mheaney@ni.net (Matthew Heaney) writes:

  > I have a question about the relationship between types, first named
  > subtypes, and base types.

  > If I declare an integer type, say

  > type T is range 1 .. 10;

  > Then I think that according to the Ada model this means I'm declaring some
  > unnamed type, but whose first named subtype is T:

  > type <anonomous parent of T> is System.Min_Int .. System.Max_Int;
  > subtype T is <anonomous parent of T> range 1 .. 10;

  > Do I have this correct?

  No.  The range of the anonomous type must be at least -15..15, but
the actual range is implementation dependent.

  > Now what is the relationship of T'Base to this model?  Is T'Base the name
  > of the anonomous parent type

  > type T'Base is System.Min_Int .. System.Max_Int;
  > subtype T is T'Base range 1 ..  10;

  There is no notation for declaring such an integer type in Ada.  The
type has a 'First and 'Last, but it has NO range constraint.

  > Did the "anonmous parent" go away in Ada 95?  Or is it still

  > type <anon> is range System.Min_Int .. System.Max_Int;
  > subtype T is <anon> range 1 .. 10;

  Arrggh!  One of the worst bugs in the Ada 83 RM, long since fixed.
So yes, it is gone in Ada 95.  (Well, not the anonymous type.  The
idea that there is a possible "equivalent" declaration in Ada.)

  > and T'Base simply "refers" to this anonomous type?

  Technically T'Base is a subtype of the anonomous type which contains
no constraint:

  subtype T'BASE is <anon>;

  > I can declare objects of type T'Base, right?

  > O : T'Base;

   Yes, but please don't name them O.

  > Is this declaration the same as

  > O : <anonomous parent of T>;

   Other than the fact that the second declaration is not legal in
Ada?  Not much difference.  Just remember that T'Base is a subtype of
the anonymous type which applies no constraint, and you are all set.

  > Enquiring minds want to know...

    Watch out, soon you may turn into a language lawyer.
--

					Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




  parent reply	other threads:[~1997-01-28  0:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-26  0:00 Question about base types Matthew Heaney
1997-01-27  0:00 ` Robert A Duff
1997-01-30  0:00   ` Matthew Heaney
1997-01-30  0:00     ` Robert Dewar
1997-01-30  0:00       ` Matthew Heaney
1997-01-30  0:00     ` Matthew Heaney
     [not found]     ` <EACHUS.97Feb3221558@spectre.mitre.org>
     [not found]       ` <dewar.855063927@merv>
     [not found]         ` <EACHUS.97Feb6145918@spectre.mitre.org>
     [not found]           ` <dewar.855276722@merv>
1997-02-07  0:00             ` Mats Weber
1997-02-08  0:00               ` Robert Dewar
1997-02-10  0:00                 ` Mats Weber
1997-02-11  0:00                   ` Robert Dewar
     [not found]         ` <32FB45D4.2160@watson.ibm.com>
1997-02-10  0:00           ` Robert Dewar
1997-02-08  0:00   ` Robert Dewar
1997-02-09  0:00     ` Matthew Heaney
1997-02-09  0:00       ` Robert Dewar
1997-02-09  0:00         ` Matthew Heaney
1997-02-10  0:00           ` Robert Dewar
1997-02-10  0:00       ` Larry Kilgallen
1997-02-11  0:00   ` Robert I. Eachus
1997-02-12  0:00     ` Robert Dewar
1997-01-27  0:00 ` Mats Weber
1997-01-28  0:00   ` Robert A Duff
1997-01-29  0:00   ` Robert Dewar
1997-01-28  0:00 ` Robert I. Eachus [this message]
1997-01-28  0:00   ` Mats Weber
1997-01-29  0:00 ` Robert I. Eachus
1997-01-30  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