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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,147f221051e5a63d X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!feeder3.cambrium.nl!feed.tweaknews.nl!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: memory management in Ada: tedious without GC? References: <4ddef8bf-b5b1-4d7e-b75b-386cd6c8402c@l17g2000pri.googlegroups.com> Date: Fri, 16 May 2008 20:56:50 +0200 Message-ID: <87skwiulfx.fsf@ludovic-brenta.org> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:zKxHFBwxG3bd7bcTZCTFZ+Cna78= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Organization: Tele2 X-Trace: DXC=k_9591R6`Y6aWje^YZETC3PXeOI]_1B4<]HH1:nS?N]F2>mS4k[`OeeekCOJ0^ Xref: g2news1.google.com comp.lang.ada:114 Date: 2008-05-16T20:56:50+02:00 List-Id: "jhc0033@gmail.com" writes: > I'm mostly soliciting answers from Ada programmers who know C++ RAII > well (Skip this if you use the words "C" and "C++" interchangeably, > please. Your answers will be misleading at best): > > As I understood from reading the Memory Management section of > Wikibooks on Ada, Ada's memory management facilities are roughly > equivalent to > > a. C++-like "new" > b. C++-like "delete" > c. Java-like "finally" > d. your implementation may or may not have GC > > Did I misunderstand? No, but you didn't get the entire picture. > To me, this seems much, much more error-prone and tedious that C++'s > RAII approach, where you almost never have to worry about deallocation > (i.e. "b" and "c" above), even in the presence of exceptions, unless > you have GC. Besides, RAII applies to a bunch of other things, like > thread locks, database connections, files - not just memory. Read up on "controlled types" and, in the ARM, on Ada.Finalization, as well as "storage pools". That will complete your understanding of Ada's memory management. -- Ludovic Brenta.