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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no 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!news2.google.com!proxad.net!proxad.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Ada.Containers.Vectors - querying multiple elements Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <426e4c2b$0$7515$9b4e6d93@newsread2.arcor-online.net> <0uYbe.542$BE3.229@newsread2.news.pas.earthlink.net> Date: Fri, 29 Apr 2005 09:52:14 +0200 Message-ID: <1wjh6qsazg3rg$.lupowyuqu0tw$.dlg@40tude.net> NNTP-Posting-Date: 29 Apr 2005 09:52:14 MEST NNTP-Posting-Host: d4992e71.newsread2.arcor-online.net X-Trace: DXC=fdE\`fFAiURUEj^fn36YV^Q5U85hF6f;TjW\KbG]kaMX:cmYYm_h3\SnL]o^6FWH;VWRXZ37ga[7Zn919Q4_`VjYB8=X\UUgbkT X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:10803 Date: 2005-04-29T09:52:14+02:00 List-Id: On Thu, 28 Apr 2005 15:55:25 -0500, Randy Brukardt wrote: > "Jeffrey Carter" wrote in message > news:0uYbe.542$BE3.229@newsread2.news.pas.earthlink.net... > ... >> 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. > > 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. > > 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. I wonder if introducing ranges as a type class could mend this. Provided a fictitious attribute Enum'Range (0) would return a null-length range, one could then create empty arrays without referencing to any concrete index bounds. But then Obj'First and Obj'Last could potentially raise Constraint_Error, which might appear unpleasant but perfectly consistent. Could there be a distributed overhead in the implementations of 'First and 'Last then? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de