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-Thread: 103376,1fa85f3df5841ae1 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!newsread2.news.pas.earthlink.net.POSTED!a6202946!not-for-mail From: Jeffrey Carter Organization: jrcarter commercial-at acm [period | full stop] org User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.7.3) Gecko/20040910 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada.Containers.Vectors - querying multiple elements References: <426e4c2b$0$7515$9b4e6d93@newsread2.arcor-online.net> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <0uYbe.542$BE3.229@newsread2.news.pas.earthlink.net> Date: Thu, 28 Apr 2005 03:09:48 GMT NNTP-Posting-Host: 4.240.242.204 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.pas.earthlink.net 1114657788 4.240.242.204 (Wed, 27 Apr 2005 20:09:48 PDT) NNTP-Posting-Date: Wed, 27 Apr 2005 20:09:48 PDT Xref: g2news1.google.com comp.lang.ada:10771 Date: 2005-04-28T03:09:48+00:00 List-Id: Randy Brukardt wrote: > "Jeffrey Carter" wrote in message > news:R_Ebe.13911$lP1.2554@newsread1.news.pas.earthlink.net... > ... > >>Unlike the Vector container that will be part of Ada 0X, this has no >>restrictions on the Index subtype. Any discrete type is acceptable. > > Of course, you did that by having a goofy definition for Last: > > if Length(S0) = 0, Last(S0) = Index'First. > if Length(S1) = 1, Last(S1) = Index'First. It doesn't seem so goofy to me. The test for a null unbounded array is "S = Null_Unbounded_Array" or Length (S) = 0. Last is pretty meaningless if the array is null, so having it return something meaningless seemed better than having it raise an exception. If Length (S) = 1, then Last = First, by definition, so Last (S) = Index'First. There didn't seem to be any way to return an appropriate result from To_Fixed if the unbounded array was null, so it raises an exception. The definition of Last was driven by the decision to allow null unbounded arrays regardless of the base range of Index. Currently, unconstrained Ada array types can exist that don't have null arrays. IIRC, this will be corrected in Ada 0X; if you allow them for arrays, you ought to allow them for the unbounded-array abstraction. -- Jeff Carter "Son of a window-dresser." Monty Python & the Holy Grail 12