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!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: Introductory Presentations, especially aimed at C++ programmers! Date: Fri, 9 Dec 2016 15:18:24 -0700 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <1905815374.502825168.454102.laguest-archeia.com@nntp.aioe.org> <877f7b5llo.fsf@nightsong.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 9 Dec 2016 22:17:05 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="55132178a71021b7c7c45699e701f7c3"; logging-data="23708"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18AvQnmqv/JD4uJMV0kCbmdXX70Bb1Y7NI=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.5.1 In-Reply-To: Cancel-Lock: sha1:lmucd3gcf8ym+5X4sfPHXj05KDs= Xref: news.eternal-september.org comp.lang.ada:32707 Date: 2016-12-09T15:18:24-07:00 List-Id: On 12/09/2016 03:01 PM, Randy Brukardt wrote: > "Paul Rubin" wrote in message > news:877f7b5llo.fsf@nightsong.com... >>> exponentially better than being prevented from overflowing a buffer is >>> being able to figure out how to do >>> declare >>> B : Buffer (1 .. Just_The_Right_Size); >> >> Alternatively the buffer could be dynamically sized according to the >> data. That's not in the Ada spirit because of the possible OOM and >> memory allocation latency getting in the way of embedded realtime >> applications, but for a workstation app it's perfectly workable. >> Horses for courses. > > That's one possible way to use the API in question, since there's no way to > find out beforehand how much data you'll need. (You could ask for the size > ahead of time, but of course that's a potential race condition so it doesn't > really help.) I was including in being able to do declare B : Buffer (1 .. Just_The_Right_Size); such things as declare S : String := Get_Line; and there's usually a way to do that even when you don't know beforehand how big the result will be. After all, the Get_Line function doesn't know beforehand how long a String it will return. I don't how the API in question works, so I can't say for sure if there's a way to do this for it, but there usually is. -- Jeff Carter "If you don't get the President of the United States on that phone, ... you're going to have to answer to the Coca-Cola Company." Dr. Strangelove 32