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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!aioe.org!.POSTED!not-for-mail From: =?UTF-8?B?TWFya3VzIFNjaMO2cGZsaW4=?= Newsgroups: comp.lang.ada Subject: Surprising behaviour of strings.fixed.overwrite Date: Wed, 12 Nov 2014 11:49:29 +0100 Organization: Aioe.org NNTP Server Message-ID: NNTP-Posting-Host: MdpKeRr+sx3LK7JQiK5aNw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: news.eternal-september.org comp.lang.ada:23153 Date: 2014-11-12T11:49:29+01:00 List-Id: Given the following Ada program: ---%<--- with TEXT_IO; with ADA.STRINGS; with ADA.STRINGS.FIXED; procedure TEST is S : STRING(1 .. 6); begin S := "@@@@@@"; ADA.STRINGS.FIXED.OVERWRITE (S, S'First + 5, "56", ADA.STRINGS.LEFT); TEXT_IO.PUT_LINE (S); S := "@@@@@@"; ADA.STRINGS.FIXED.OVERWRITE (S, S'First + 5, "56", ADA.STRINGS.RIGHT); TEXT_IO.PUT_LINE (S); end; --->%--- What would you expect to be the output of the program? Scroll down for the answer... Well, I would have expected the output to be @@@@@6 @@@@@5 But it is: @@@@56 @@@@@5 Which is correct according to the definition of overwrite, but nevertheless I find this extremely surprising. Am I alone in this? Or can anyone please the rational on defining the behaviour of overwrite as it is? Markus