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,1cb75f0476fe2d1a X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Half Constrained Array Types and Slices Date: 10 Mar 2006 12:38:58 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1141667416.163432.304280@p10g2000cwp.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1142012338 3320 192.74.137.71 (10 Mar 2006 17:38:58 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 10 Mar 2006 17:38:58 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:3326 Date: 2006-03-10T12:38:58-05:00 List-Id: "Jeffrey R. Carter" writes: > I think the index type should be discrete. But surely it doesn't need to > be an integer: > > with Ada.Text_IO; > procedure Null_Range is > type A is (B, C); > > type D is array (A range <>) of Integer; > > E : D (C .. B); > begin -- Null_Range > Ada.Text_IO.Put_Line (Item => A'Image (E'Last) ); > end Null_Range; > > This is valid Ada. Indeed it is. I don't think it's very useful, however. My claim is that if you want empty arrays, you almost certainly want to index them by (non-modular) integers. Which is why I'm happy with the restriction in the Containers library that Vector indices must be signed integers. >... With GNAT, it outputs B. However, if D were a string > type, "" would not be valid for it. > > > The idea that 'Range is equivalent to 'First..'Last seems reasonable to > > me... > > I'm not saying it's a good idea. I'm just wondering what the > consequences of it are. I suppose the consequence is bugs -- rare cases where 'First and/or 'Last surprisingly raise Constraint_Error. - Bob