From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-3.2 required=3.0 tests=BAYES_00,NICE_REPLY_A, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R.Carter" Newsgroups: comp.lang.ada Subject: Re: problemn with string'last Date: Fri, 5 May 2023 13:17:49 +0200 Organization: A noiseless patient Spider Message-ID: References: <2bc1705c-7802-4e89-960f-9b566d376f3cn@googlegroups.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Fri, 5 May 2023 11:17:49 -0000 (UTC) Injection-Info: dont-email.me; posting-host="ff5db5f91a086dc243442759fe56ad04"; logging-data="2439969"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Ap7SKaJ2QkSi2My9nB+7gwCgWx7PqyaQ=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Cancel-Lock: sha1:9YEwO5jQamNAbWytns+tz4jSIgM= Content-Language: en-US In-Reply-To: <2bc1705c-7802-4e89-960f-9b566d376f3cn@googlegroups.com> Xref: news.eternal-september.org comp.lang.ada:65173 List-Id: On 2023-05-05 11:51, Daniel Gaudry wrote: > > Ada.Text_Io.Put_Line(" 05 10 15 20 25 30 35 40 45 50 55 65 70 75 80 85 90"); > Ada.Text_Io.Put_Line(" ....|....!....|....!....|....!....|....!....|....!....|....!....|....!....|....!....|....!"); > Ada.Text_Io.Put_Line("»" & Data & "« " & Data'Last'Img); As Kazakov pointed out, your scale is incorrect. However, it's important to remember that 'Last is not necessarily the same as 'Length because 'First is not necessarily one. This is especially important in subprograms that take String parameters, as they are often passed slices. Some questions: > Double_Quote : constant String(1 .. 1) := (others => '"' ); ARM 2.1(15/3) (http://www.ada-auth.org/standards/aarm12_w_tc1/html/AA-2-1.html#I1199) defines the name of '"' as "quotation mark". Why do you refer to a single quotation mark as Double_Quote? > Data : constant String := " PLUS_STRING : CONSTANT STRING(1..3) :=(1 =>'" & Double_Quote & "' , 2 =>'+' , 3 =>'" & Double_Quote & ");"; Wouldn't it be simpler and clearer to write this as Data : constant String := " PLUS_STRING : CONSTANT STRING := " & '"' & '+' & '"'; ? Note also that you seem to be missing an apostrophe (''') before the right parenthesis if you intend Data to be a valid Ada declaration. -- Jeff Carter "All citizens will be required to change their underwear every half hour. Underwear will be worn on the outside, so we can check." Bananas 29