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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,345a8b767542016e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-03-16 06:56:26 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.cwix.com!news.compuserve.com!news-master.compuserve.com!not-for-mail From: DPH Newsgroups: comp.lang.ada Subject: Re: memory leakages with Ada? Date: Sat, 16 Mar 2002 09:56:41 -0500 Organization: CompuServe Interactive Services Message-ID: <3pm69u85j4h7efndahkean6trom5utk21m@4ax.com> References: <3c90af1e@news.starhub.net.sg> <3c91bfa3.1987537@news.demon.co.uk> NNTP-Posting-Host: mid-tgn-ngy-vty156.as.wcom.net Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: suaar1aa.prod.compuserve.com 1016290585 25862 216.192.89.156 (16 Mar 2002 14:56:25 GMT) X-Complaints-To: newsmaster@compuserve.com NNTP-Posting-Date: 16 Mar 2002 14:56:25 GMT X-Newsreader: Forte Agent 1.8/32.548 Xref: archiver1.google.com comp.lang.ada:21333 Date: 2002-03-16T14:56:25+00:00 List-Id: On Sat, 16 Mar 2002 14:38:32 GMT, "Pat Rogers" wrote: >"DPH" wrote in message >news:s3369uo70srjh7m4pjkgt6n4kpt88hdeb8@4ax.com... >> On Fri, 15 Mar 2002 12:55:19 GMT, "Pat Rogers" >> wrote: >> >> >"John McCabe" wrote in message >> >news:3c91bfa3.1987537@news.demon.co.uk... >> >> On Thu, 14 Mar 2002 15:12:21 -0500, "Marin David Condic" >> >> wrote: >> >> >> >> >In comparing Ada to C on this there are two observations: One is that Ada >> >> >provides a different model for dynamic allocation than does C that >includes, >> >> >among other things, a lot more checks/safety features to minimize the >> >> >possibility of lost memory. (Still, the standard doesn't require garbage >> >> >collection so you can still leak memory if you mess things up.) It isn't >> >> >impossible to leak memory in Ada - just less likely. >> >> >> >> One of the things I've found recently, since starting to use C++ more, >> >> is that Ada.UncheckedDeallocation is so much nicer than 'delete' as it >> >> returns you a nice, null pointer! 'delete' in C++ appears to remove >> >> the allocated block, but leave your pointer pointing to where it used >> >> to be! >> > >> >Although there are several things I really like about C++, one of the things >> >that I find shocking is that the programmer must remember to use a very >slightly >> >different syntax when calling delete on an allocated array, and that the >other >> >syntax will also compile and run -- and at the very least leak. (I >understand >> >the reason for this, don't bother to explain why; it still stinks!) That >isn't >> >the only such example, of course, but one that I find amazing. >> > >> >For example, the following is perfectly legal and wrong : >> > >> >char* p = new char[n]; >> >delete p; >> > >> >I have to remember to say: >> > >> >delete[] p; >> >> No you don't... you just write it with Borland C++ Builder 5 or better >> with CodeGuard turned on, and CodeGuard will complain about it all >> over the place. > >But then why can't the compiler do that? > Well, they _could_ build it in if they wanted to, and since its part of the IDE it might be said to be part of the compiler already, but this goes back to a post I made last month. I'm just wondering if Ada is all that much less error prone when you start comparing it with C++ development environments in the wildly popular platforms of Windows and Linux, but especially windows. There are just scads of tools to do about everything (except reliably find the memory leaks of C++, although there may be - and I just haven't run across it yet) and those tools are generally cheaper due to economy of scale. Don't get me wrong - I love Ada - but cheap and plentiful tools for other languages count for something, too. Couple that with being able to find 10 - 20 C++ programmers for every Ada programmer, and Ada loses a lot of business. Dave Head