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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b41c04fc501479d6,start X-Google-Attributes: gid103376,public From: Jeff Carter Subject: Lower bound of result of Ada.Strings.Unbounded.Slice Date: 2000/11/21 Message-ID: <3A1B087B.D45A8751@acm.org>#1/1 X-Deja-AN: 696368959 Content-Transfer-Encoding: 7bit X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.prod.itd.earthlink.net 974850175 165.121.229.76 (Tue, 21 Nov 2000 15:42:55 PST) Organization: EarthLink Inc. -- http://www.EarthLink.net MIME-Version: 1.0 NNTP-Posting-Date: Tue, 21 Nov 2000 15:42:55 PST Newsgroups: comp.lang.ada Date: 2000-11-21T00:00:00+00:00 List-Id: Consider the following program: with Ada.Strings.Unbounded; with Ada.Text_Io; use Ada.Strings.Unbounded; use Ada.Text_Io; procedure Slice_Test is Line : constant String := "This is a nice long line."; U_Line : constant Unbounded_String := To_Unbounded_String (Line); begin -- Slice_Test Put_Line ("Slice (U_Line, 3, 7)'First =>" & Integer'Image (Slice (U_Line, 3, 7)'First) & "; Slice (U_Line, 3, 7)'Last =>" & Integer'Image (Slice (U_Line, 3, 7)'Last) ); end Slice_Test; Compiler A has 1 and 5 in its output, while compiler B has 3 and 7. As far as I can tell from the ARM, both results are acceptable. So are 22 and 26. This makes it difficult to write portable code that uses an index in the result of Slice to access a position in the whole string. Consistency across compilers here would be a Good Thing, IMHO. The value of the Low parameter to Slice would be the better lower bound, I think, since it is what you get with type String. Is this something I should submit as a potential AI? -- Jeff Carter "Nobody expects the Spanish Inquisition!" Monty Python's Flying Circus