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!news3.google.com!newshub.sdsu.edu!npeer.de.kpn-eurorings.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> <1wjh6qsazg3rg$.lupowyuqu0tw$.dlg@40tude.net> <1O2dnYJF_uSxAejfRVn-2Q@megapath.net> Date: Mon, 2 May 2005 19:04:32 +0200 Message-ID: <14ts2mrny7fci.emc3y6pqq7za$.dlg@40tude.net> NNTP-Posting-Date: 02 May 2005 19:04:22 MEST NNTP-Posting-Host: 8687b552.newsread2.arcor-online.net X-Trace: DXC=iZ1]o]H2Q^SYFAnNd=0_4TQ5U85hF6f;TjW\KbG]kaMX:cmYYm_h3\SM3eMe_?AHe\WRXZ37ga[7ZncfD5BXcIXPg`L;[NcETR_ X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:10877 Date: 2005-05-02T19:04:22+02:00 List-Id: On Sun, 1 May 2005 22:21:42 -0500, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:txah28f4zlnp$.1pqea609lovyn.dlg@40tude.net... > ... >> Now consider the following test: >> >> type T is mod 1; >> type T_Array is array (T range <>); >> X : T_Array := ; >> begin >> for I in X'Range loop -- This is OK >> null; >> end loop; >> for I in X'First..X'Last loop -- This cannot be OK >> null; >> end loop; >> >> Which is in a perfect contradiction with 3.6.2(7). It could probably be >> mended too if we had universal index types. But this is yet another story. > > In Ada as currently defined, you would get Constraint_Error from the attempt > to define the bounds. That happens with string types: > > type T is mod 1; > type T_Array is array (T range <>) of Character; > X : T_Array := ""; -- Raises Constraint_Error > > There is actually an ACATS test to check this. (I remember it because one > vendor disputed the test; it was upheld.) So "" is not allowed for any string type which index is not a subtype/derived type S of some base type T, such that S'First>T'First. With a nice consequence that: type T1 is range -2147483647..0; type T1_Array is array (T range <>) of Character; type T2 is range -2147483648..0; type T2_Array is array (T range <>) of Character; type T3 is range -2147483649..0; type T3_Array is array (T range <>) of Character; X : T1_Array := ""; -- Legal Y : T2_Array := ""; -- Illegal Z : T3_Array := ""; -- Again legal!!!!! That's really funny. What is so special in the number -2147483648? Should it mean that potentially no program that uses negative indices and empty strings is portable, you never know where *a* built-in integer type may start? -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de