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!newsread3.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> <0uYbe.542$BE3.229@newsread2.news.pas.earthlink.net> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Fri, 29 Apr 2005 02:54:05 GMT NNTP-Posting-Host: 4.240.245.113 X-Complaints-To: abuse@earthlink.net X-Trace: newsread3.news.pas.earthlink.net 1114743245 4.240.245.113 (Thu, 28 Apr 2005 19:54:05 PDT) NNTP-Posting-Date: Thu, 28 Apr 2005 19:54:05 PDT Xref: g2news1.google.com comp.lang.ada:10796 Date: 2005-04-29T02:54:05+00:00 List-Id: Randy Brukardt wrote: > It's not really corrected in Ada 2006; it has additional aggregates that > help, but the basic problem of having to mess with the bounds still exists: > > Obj : Some_Array (Enum'First .. > Enum'Val(Enum'Pos(Enum'First)+Some_Length-1); > > doesn't work if Some_Length = 0 and there is no general way to fix that. You > just have to special case Some_Length = 0 and that is unpleasant. Right, but you can say Obj : Some_Array := Some_Array'(<>); (I hope I've remembered the syntax correctly) and Obj'Length = 0; there was no way to do this before if Enum'First = Enum'Last. And you should be able to convert Obj into a corresponding unbounded array. > The solution that Ada.Containers.Vector took to this problem is essentially > to ban instantiating it with subtypes where 'First = 'Base'First. (OK, you > can do the instantiation, but it will raise Constraint_Error.) One can argue > whether that is the best solution, but it seems clear that all of the > possible solutions are ugly. Yes. I think this solution is uglier than having Last = First if Length = 0. -- Jeff Carter "Beyond 100,000 lines of code you should probably be coding in Ada." P. J. Plauger 26