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,1b6f0735bc6de58e X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: index check failure - constraint error Date: Fri, 01 Apr 2011 19:29:31 -0400 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <8fc6d308-c548-4efc-9f5d-aa1bc37742d8@dr5g2000vbb.googlegroups.com> <716e8fba-c396-4d47-81ef-c7b275f919a8@f15g2000pro.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls6.std.com 1301700571 24955 192.74.137.71 (1 Apr 2011 23:29:31 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 1 Apr 2011 23:29:31 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:54W29aErGTWDJ5jkCVzR4Tcswzg= Xref: g2news1.google.com comp.lang.ada:18676 Date: 2011-04-01T19:29:31-04:00 List-Id: Adam Beneschan writes: > On Apr 1, 3:49�pm, Robert A Duff wrote: >> Jeffrey Carter writes: >> > The idea that Strings always have a lower bound of 1 is quite common >> > among beginners. >> >> Whereas experts understand that it OUGHT to be true that >> "Strings always have a lower bound of 1", but it isn't true. >> It's a design flaw in the Ada language. >> >> > In SPARK all Strings do have a lower bound of 1. >> >> As they should. �It really makes things simpler. >> And (could be) more efficient. > > I dunno. I kind of like it that if I'm parsing a string, and I call > > Next_Item := Ada.Strings.Fixed.Index_Non_Blank (S > (Current_Index .. S'Last)); > > then Next_Item is the index of the actual character in S that I need, > and I don't need to add Current_Index to it and then think about > whether I need to add 1 or subtract 1 from the sum, as I'd have to do > something like that if Index_Non_Blank saw its Source parameter as a > string with a lower bound of 1. Good point. But I think that's what cursors are for. I still think indices into Strings ought to be 1-based. - Bob