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!reader01.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R.Carter" Newsgroups: comp.lang.ada Subject: Re: String view of file Date: Mon, 21 Nov 2022 17:42:56 +0100 Organization: A noiseless patient Spider Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Mon, 21 Nov 2022 16:42:57 -0000 (UTC) Injection-Info: reader01.eternal-september.org; posting-host="656c6272d9b5e625a532946caa503524"; logging-data="4006500"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+Llxdi4Cp4PgljYYc+E4NgXsljcmf5U38=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 Cancel-Lock: sha1:BbJaWoz0Lt2GW9YM9Dk3ZtrQmCs= Content-Language: en-US In-Reply-To: Xref: reader01.eternal-september.org comp.lang.ada:64652 List-Id: On 2022-11-21 16:52, Niklas Holsti wrote: > > For the OP's benefit (Jeffrey of course knows this): an alternative to > Unbounded_String is to allocate the Result string on the heap, and return an > access to the heap string. With that method, you can still read the entire > string with one call of FAS_IO.Read instead of Character by Character. I know it, and I deliberately reject it. Having access types in a pkg spec is poor design. Delegating the associated memory management and all its opportunities for error to the pkg client is very poor design. If access types are used, they should be hidden and encapsulated with their memory management. This makes it easier to get the memory management correct. Since this is what using Unbounded_String does for you, I think it's better to use it than to expend extra effort doing something similar. -- Jeff Carter "I have a very small head and I had better learn to live with it ..." Edsger Dijkstra 158