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!feeder.eternal-september.org!news.unit0.net!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: How to get Ada to ?cross the chasm?? Date: Fri, 11 May 2018 10:21:41 +0300 Organization: Tidorum Ltd Message-ID: References: <1c73f159-eae4-4ae7-a348-03964b007197@googlegroups.com> <87zi1gz3kl.fsf@nightsong.com> <878t8x7k1j.fsf@nightsong.com> <87k1sg2qux.fsf@nightsong.com> <87h8njmk4r.fsf@nightsong.com> <87po27fbv9.fsf@nightsong.com> <87h8nhwhef.fsf@nightsong.com> <87d0y4zf7d.fsf@nightsong.com> <87tvrfyvha.fsf@nightsong.com> Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 0s/urQpHSPyC3dE2EBaCbAw53lS18/uPL/bnAmQreMxSdNQ3p7 Cancel-Lock: sha1:wpk5XYYscU5Zcoqf7pIx7tLq/3A= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 In-Reply-To: <87tvrfyvha.fsf@nightsong.com> Xref: reader02.eternal-september.org comp.lang.ada:52245 Date: 2018-05-11T10:21:41+03:00 List-Id: On 18-05-11 01:52 , Paul Rubin wrote: > "Randy Brukardt" writes: >> No wonder you don't understand: Ada 95 had none of the container stuff or >> other features that reduces the memory management burden without using GC. >> At a minimum, you need to consider Ada 2005, but the most recent Ada is >> best. > > Ah, ok, I was also going by > > http://cowlark.com/2014-04-27-ada/index.html > > which claims Ada has no standardized way to release allocated memory (so > each implementation had its own way). That summary of Ada has many inaccuracies, but mostly minor ones. Pity that they have not been corrected (some of the examples are syntactically wrong, too). For releasing allocated heap memory, Ada.Unchecked_Deallocation is just as standard as "free" in C. People are just scared by the name, and by the asymmetry between the simple, primitive "new" keyword and the long library-level name Unchecked_Deallocation. Logically, perhaps Ada should not have included a "new" keyword to allocate heap memory, but should have had something like a generic library function Ada.Unchecked_Allocation, which is "unchecked" in the sense that there is no guarantee that the allocated memory will be released when no longer needed. I can imagine the confusion that would have caused... > If you can suggest a good place > to read about the current standard method I'd appreciate it. The idea is just to use the standard containers, including the ones that can handle indefinite types like String, instead of doing "new" and Unchecked_Deallocation yourself. And to use cursors pointing to elements of a container, instead of using visible access types. The containers then manage the heap allocations and releases. However, I don't think this method will free you from worrying about dangling references -- I believe a cursor can be left dangling, just as an access value can be. (I haven't yet had occasion to do such container-centric Ada programming, although I have used the Ada containers in less central roles.) -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .