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,2fa53692def716b5 X-Google-Attributes: gid103376,public From: "Matthew Heaney" Subject: Re: null range from 1 element discrete type Date: 1999/11/19 Message-ID: <3835671c_2@news1.prserv.net>#1/1 X-Deja-AN: 550559303 Content-transfer-encoding: 7bit References: Content-Type: text/plain; charset="US-ASCII" X-Complaints-To: abuse@prserv.net X-Trace: 19 Nov 1999 15:05:00 GMT, 32.101.8.40 Organization: Global Network Services - Remote Access Mail & News Services Mime-version: 1.0 Newsgroups: comp.lang.ada Date: 1999-11-19T00:00:00+00:00 List-Id: In article , Duncan Sands wrote: > Suppose I have a discrete type (eg an enumeration type) T > containing just one element. I would like to define a subtype > with a null range. If T had more than one element, I could use > T'Last .. T'First, but this won't work here. How to get a null > range in this case? You're allowed to violate the range of the subtype, e.g. S : String (1 .. 0); is perfectly OK, even though 0 is outside the range of the index subtype Positive, because it is still in the range of Integer'Base. The problem is that an enumeration type is its own "base type." You could try this: type ET is (A); subtype Null_ET is ET range A .. ET'Pred (A); but I don't think this will work, because there is no predecessor of A. The base type of ET, ET'Base, only includes the values A .. A. A solution is to declare a base type with extra values, and declare ET as a subtype, like this: type ET_Base is (ET_Base_First, A, ET_Base_Last); subtype ET is ET_Base range A .. A; Now you're free to declare another subtype, of ET, with a null range: subtype Null_ET is range A .. ET'Pred (A); which should work fine. -- "It is indeed remarkable that this theory [of evolution] has progressively taken root in the minds of researchers following a series of discoveries made in different spheres of knowledge," the Pope said. "The convergence, neither sought nor provoked, of results of studies undertaken independently from each other constitutes in itself a significant argument in favour of this theory." Pope John Paul, 24 Oct 96