From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,d57302f2954365e1 X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Question about base types Date: 1997/01/28 Message-ID: #1/1 X-Deja-AN: 212638189 references: organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.ada Date: 1997-01-28T00:00:00+00:00 List-Id: In article 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 is System.Min_Int .. System.Max_Int; > subtype T is 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 is range System.Min_Int .. System.Max_Int; > subtype T is 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 ; > 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 : ; 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...