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!2.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: String view of file Date: Mon, 21 Nov 2022 19:29:12 +0200 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net HYtzPAdNuuC+wGqTyp2DrQEHRBe7RWkFZxucfNzOLkQTskPhtW Cancel-Lock: sha1:HUznoCNQM3OrzGNkNXUYrs01+8I= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:102.0) Gecko/20100101 Thunderbird/102.4.1 Content-Language: en-US In-Reply-To: Xref: reader01.eternal-september.org comp.lang.ada:64653 List-Id: On 2022-11-21 18:42, Jeffrey R.Carter wrote: > 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. I agree in general, but there are design trade-offs that depend on issues not made clear in the original question, such as the size of the file and the performance requirements. So I thought that the OP should know of the heap alternative, even if it has some poorer properties too.