comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <matthew_heaney@acm.org>
Subject: Re: Ammo-zilla
Date: 1999/10/24
Date: 1999-10-24T00:00:00+00:00	[thread overview]
Message-ID: <381324b9_1@news1.prserv.net> (raw)
In-Reply-To: 7uutgd$87h$1@nnrp1.deja.com

In article <7uutgd$87h$1@nnrp1.deja.com> , Robert Dewar 
<robert_dewar@my-deja.com>  wrote:

>> that there's a lot of memory leaks in it, which Ada is a lot better for.
>
>
> Now that's an interesting comment, because to me C++ and Ada
> are identical in this particular department, can you explain
> why you think Ada is better wrt memory leaks?


I can't speak for the original poster, but perhaps one reason is that
functions in Ada can return unconstrained array types, eliminating the
need to heap use, and therefore eliminating a source of memory leaks.

I agree with Robert, but I'd go further and say that here C++ is
superior to Ada95, because you can implement true "smart pointers" (by
overriding the dereference operator "->") that reclaim memory
automatically.

You can do something very similar in Ada95 though, by wrapping the raw
access object in a Controlled type and using unary plus to return the
value.  For example:

  type Bool_Exp is abstract tagged limited private;

  type Bool_Exp_Access is access all Bool_Exp'Class;

  -- Here's the smart pointer type:
  type Exp_Handle is private;

  function "+" (Handle : Exp_Handle) return Bool_Exp_Access;


The article "Smart Pointers", in the patterns archive, describes the
technique.

<http://www.acm.org/archives/patterns.html>

(Use the search engine for find the word "smart" in the subject line.)


Perhaps in a future version of the language controlled-ness (or some
other form of garbage collection) can be applied to access types
directly.  For now, the smart pointer idiom isn't too much pain.




      parent reply	other threads:[~1999-10-24  0:00 UTC|newest]

Thread overview: 92+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-10-23  0:00 Ammo-zilla Stanley R. Allen
1999-10-24  0:00 ` Ammo-zilla Robert Dewar
1999-10-24  0:00   ` Ammo-zilla David Botton
1999-10-24  0:00 ` Ammo-zilla Aidan Skinner
1999-10-24  0:00   ` Ammo-zilla Robert Dewar
1999-10-24  0:00     ` Ammo-zilla David Botton
1999-10-28  0:00       ` Ammo-zilla Charles Hixson
1999-10-28  0:00         ` Ammo-zilla Laurent Guerby
1999-10-28  0:00           ` Ammo-zilla David Starner
1999-10-29  0:00             ` Ammo-zilla Larry Kilgallen
1999-10-29  0:00               ` Ammo-zilla David Starner
1999-10-29  0:00                 ` Ammo-zilla Matthew Heaney
1999-10-29  0:00                   ` Ammo-zilla Charles Hixson
1999-10-29  0:00                 ` Ammo-zilla David Botton
1999-10-29  0:00                   ` Ammo-zilla mike
1999-10-29  0:00                     ` Ammo-zilla David Botton
1999-10-31  0:00                     ` Ammo-zilla Robert Dewar
1999-11-02  0:00                       ` Ammo-zilla Charles Hixson
1999-11-03  0:00                         ` Ammo-zilla Wes Groleau
1999-11-01  0:00                     ` Ammo-zilla Geoff Bull
1999-10-29  0:00                 ` Ammo-zilla Tucker Taft
1999-10-30  0:00                   ` Ammo-zilla Lutz Donnerhacke
1999-10-31  0:00                 ` Ammo-zilla Robert Dewar
1999-10-31  0:00                   ` Garbage colletion Lutz Donnerhacke
1999-11-01  0:00                     ` Robert Dewar
1999-11-01  0:00                       ` Lutz Donnerhacke
1999-11-01  0:00                     ` Larry Kilgallen
1999-11-01  0:00                     ` Robert Dewar
1999-11-01  0:00                       ` Gnat IDE (was: Garbage colletion) Ted Dennison
1999-11-01  0:00                       ` Garbage colletion Lutz Donnerhacke
1999-11-01  0:00                         ` Robert Dewar
1999-11-04  0:00                           ` Didier Utheza
1999-11-04  0:00                             ` David Starner
1999-10-31  0:00                 ` Ammo-zilla Robert Dewar
1999-10-31  0:00                   ` Ammo-zilla David Starner
1999-11-01  0:00                     ` Ammo-zilla Robert Dewar
1999-11-01  0:00                     ` Ammo-zilla Robert Dewar
1999-11-01  0:00                     ` Ada and GC. Was: Ammo-zilla Vladimir Olensky
1999-11-01  0:00                       ` Vladimir Olensky
1999-11-01  0:00                       ` Tucker Taft
1999-11-02  0:00                         ` Robert Dewar
1999-11-02  0:00                           ` Charles Hixson
1999-11-03  0:00                             ` Robert Dewar
1999-11-03  0:00                               ` Charles Hixson
1999-11-02  0:00                         ` Vladimir Olensky
1999-11-01  0:00                   ` Ammo-zilla Robert A Duff
1999-11-01  0:00                     ` Ammo-zilla Robert Dewar
1999-11-02  0:00                       ` Ammo-zilla Robert A Duff
1999-11-02  0:00                         ` Ammo-zilla Robert Dewar
1999-11-03  0:00                           ` Ammo-zilla Vladimir Olensky
1999-11-03  0:00                             ` Ammo-zilla Robert Dewar
1999-11-04  0:00                               ` Ada GC (was Re: Ammo-zilla) Vladimir Olensky
1999-11-06  0:00                                 ` Robert Dewar
1999-11-06  0:00                                   ` Vladimir Olensky
1999-11-06  0:00                                     ` Robert Dewar
1999-11-06  0:00                                     ` Vladimir Olensky
1999-11-09  0:00                                     ` Robert A Duff
1999-11-10  0:00                                       ` Vladimir Olensky
1999-11-10  0:00                                         ` Richard D Riehle
1999-11-10  0:00                                           ` Nick Roberts
1999-11-12  0:00                                             ` Robert Dewar
1999-11-12  0:00                                             ` Robert I. Eachus
1999-11-12  0:00                                               ` Didier Utheza
1999-11-10  0:00                                           ` Robert A Duff
1999-11-12  0:00                                           ` Robert I. Eachus
1999-11-04  0:00                             ` Ada GC (was Ammo-zilla) Nick Roberts
1999-11-04  0:00                               ` Wes Groleau
1999-11-01  0:00                     ` Ammo-zilla Vladimir Olensky
1999-10-30  0:00             ` Ammo-zilla Lutz Donnerhacke
1999-10-30  0:00               ` Ammo-zilla Matthew Heaney
1999-10-31  0:00             ` Ammo-zilla Robert Dewar
1999-10-28  0:00           ` Ammo-zilla Charles Hixson
1999-10-29  0:00             ` Ada and GC (Was Re: Ammo-zilla) Vladimir Olensky
1999-10-29  0:00               ` David Botton
1999-10-31  0:00                 ` Vladimir Olensky
1999-10-30  0:00                   ` Samuel T. Harris
1999-10-30  0:00                     ` David Botton
1999-10-29  0:00           ` Ammo-zilla Robert I. Eachus
1999-10-28  0:00         ` Ammo-zilla Tucker Taft
1999-10-31  0:00           ` Ammo-zilla Brian Rogoff
1999-11-01  0:00             ` Ammo-zilla Robert Dewar
1999-11-01  0:00               ` Ammo-zilla Brian Rogoff
1999-11-02  0:00                 ` Ammo-zilla Robert Dewar
1999-11-02  0:00                   ` Ammo-zilla Brian Rogoff
1999-11-02  0:00               ` Ammo-zilla Robert A Duff
1999-10-28  0:00         ` Ammo-zilla Matthew Heaney
1999-10-28  0:00           ` Ammo-zilla mitch
1999-10-29  0:00             ` Ammo-zilla Matthew Heaney
1999-10-31  0:00         ` Ammo-zilla Robert Dewar
1999-10-24  0:00     ` Ammo-zilla Aidan Skinner
1999-10-25  0:00       ` Ammo-zilla Jean-Pierre Rosen
1999-10-24  0:00     ` Matthew Heaney [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox