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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!cyclone1.gnilink.net!gnilink.net!wns14feed!worldnet.att.net!attbi_s21.POSTED!53ab2750!not-for-mail From: "Jeffrey R. Carter" User-Agent: Thunderbird 2.0.0.21 (Windows/20090302) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Number of possible values in of enumerated type References: <4a2d7a0f$1_5@news.bluewin.ch> In-Reply-To: <4a2d7a0f$1_5@news.bluewin.ch> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: NNTP-Posting-Host: 173.16.158.68 X-Complaints-To: abuse@mchsi.com X-Trace: attbi_s21 1244497553 173.16.158.68 (Mon, 08 Jun 2009 21:45:53 GMT) NNTP-Posting-Date: Mon, 08 Jun 2009 21:45:53 GMT Organization: AT&T ASP.att.net Date: Mon, 08 Jun 2009 21:45:53 GMT Xref: g2news2.google.com comp.lang.ada:6374 Date: 2009-06-08T21:45:53+00:00 List-Id: Gautier wrote: > > Did I overlook a specific attribute, or do I always need to write: > > Blah'Pos(Blah'Last)+1 > > for getting the number of possible values of an enumerated type ? You didn't overlook anything. Note, however, that your solution fails for some constrained subtypes: type E is (A, B, C); subtype F is E range B .. C; F'Pos (F'Last) = E'Pos (E'Last) = 2, so F'Pos (F'Last) + 1 gives 3, which is a problem if you want the number of values in subtype F (2). The general solution is S'Pos (S'Last) - S'Pos (S'First) + 1 -- Jeff Carter "Now look, Col. Batguano, if that really is your name." Dr. Strangelove 31