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: =?ISO-8859-15?Q?Markus_Sch=F6pflin?= Newsgroups: comp.lang.ada Subject: Re: Surprising behaviour of strings.fixed.overwrite Date: Thu, 13 Nov 2014 09:15:20 +0100 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: MdpKeRr+sx3LK7JQiK5aNw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15; format=flowed Content-Transfer-Encoding: 8bit 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:23221 Date: 2014-11-13T09:15:20+01:00 List-Id: Am 13.11.2014 um 00:19 schrieb Randy Brukardt: > "Markus Schöpflin" wrote in message > news:m3vdvn$uu$1@speranza.aioe.org... >> Given the following Ada program: > ... >> Which is correct according to the definition of overwrite, but >> nevertheless I find this extremely surprising. > > I suppose, but so what? It's not like we could change the meaning of this > routine (or any routine in Ada.Strings), as doing so would potentially > silently break existing code. True, but I suspect in this case chances are that it would actually silently fix existing code. :-) > IMHO, the vast majority of Ada.Strings.Fixed routines are rather nonsense. > I think they exist so that there are counterparts to the routines in > Ada.Strings.Unbounded, but there's rarely much reason to use them rather > than just using an appropriate slice. That's exactly what I'm trying to avoid. I tend to get the indices wrong when doing manual slicing; and I have already seen too much code getting it wrong, too. > I personally use Ada.Strings.Fixed for Index and sometimes Translate or > Move, and that's about it. Everything else I do with slices or loops > (admittedly, I started doing that back in the Ada 83 days before > Ada.Strings.Fixed existed, and there doesn't seem to be much reason to > change). I find that I have to look up the definition (both the name, the > parameters, and the semantics) for any other routine, and by the time I've > done that, I could have written a slice that would generally be faster and > smaller anyway. I was hoping to eventually remember all these things when I would finally start consistently using the standardized methods provided by Ada. But by now I think I'm better off creating my own set of functions and procedures which just do what I need, as it turns out that the standard implementation is rather slow, anyway. Markus