comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@dsd.camb.inmet.com (Bob Duff)
Subject: Re: Reference Counting (was Re: Searching Method for Incremental Garbage Collection)
Date: Fri, 2 Dec 1994 23:41:54 GMT
Date: 1994-12-02T23:41:54+00:00	[thread overview]
Message-ID: <D07J5v.Gvn@inmet.camb.inmet.com> (raw)
In-Reply-To: DAG.94Nov30090717@bellman.control.lth.se

In article <DAG.94Nov30090717@bellman.control.lth.se>,
Dag Bruck <dag@control.lth.se> wrote:
>>>>>> "R" == R William Beckwith <beckwb@ois.com> writes:
>
>R> Maybe my perspective is skewed because I have been RC'ing in Ada
>R> 9X.  I realize that C++ calls a copy constructor if you pass an
>R> object as an argument by value.  But I was under the assumption
>R> that every C++ RC'ing implementation worth its salt would require
>R> that the reference objects are passed by reference (&).

>No, why should it?  The copy constructor has to manipulate the RC,
>that's all.  If you pass arguments by reference, RC is not changed
>(you're passing the object, not its value).

In Ada 9X, all controlled types (the ones you can define reference
counting for) are passed by reference.  This seems more efficient than
passing by copy and incr/decr-ing a reference count every time.

Whether reference counting is a good idea or not (vs. "full" Garbage
Collection) is another question -- Henry Baker's many papers on the
subject are quite interesting.

>I was under the impression that the user cannot define the assignment
>operator in Ada.  If so, how can you implement safe RC except by going
>through a private type?

You cannot directly override ":=" in Ada, but ":=" always does
"adjustment", and for controlled types, you can override Adjust.
So you *can* implement safe reference counting in Ada 9X.

Controlled types are not required to be private, but they are required
to be records (or private completed as record).  So you have to wrap
your access type in a record type (a record extension actually) to make
it controlled.

Note that this is done on a per-type basis.  So some types can be
reference-counted while others are not.

>					-- Dag Bruck

- Bob
-- 
Bob Duff                                bobduff@inmet.com
Oak Tree Software, Inc.
Ada 9X Mapping/Revision Team (Intermetrics, Inc.)



  parent reply	other threads:[~1994-12-02 23:41 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CzHCvp.9rM@rheged.dircon.co.uk>
     [not found] ` <TFB.94Nov21091959@burns.cogsci.ed.ac.uk>
     [not found]   ` <RFB.94Nov27213114@cfdevx1.lehman.com>
     [not found]     ` <3be0mh$1p7@gamma.ois.com>
     [not found]       ` <3bfprn$okr@scipio.cyberstore.ca>
1994-11-29 21:27         ` Reference Counting (was Re: Searching Method for Incremental Garbage Collection) R. William Beckwith
1994-11-30  2:27           ` Henry G. Baker
     [not found]           ` <DAG.94Nov30090717@bellman.control.lth.se>
1994-11-30 16:39             ` David Weller
1994-11-30 17:58               ` Erik Naggum
1994-11-30 23:14                 ` Michael Feldman
1994-12-09 14:19                 ` Ada 95 is the name Tucker Taft
1994-12-09 22:33                   ` Pat Rogers
1994-12-11 18:59                     ` Jean D. Ichbiah
1994-12-11 20:05                       ` Pat Rogers
1994-12-16  1:01                         ` Bob Duff
1994-12-12 14:50                       ` Garlington KE
1994-12-13 21:48                         ` Tucker Taft
1994-12-14 12:44                         ` Gentle
1994-12-14 17:34                         ` Jean D. Ichbiah
1994-12-10 10:10                   ` Marc Wachowitz
1994-12-11 21:37                     ` Bob Duff
1994-12-02 23:41             ` Bob Duff [this message]
1994-12-03  8:16               ` Reference Counting (was Re: Searching Method for Incremental Garbage Collection) Bill Birch
1994-11-30 18:59           ` Hans Boehm
1994-12-01  3:20             ` R. William Beckwith
1994-12-01  3:51               ` R. William Beckwith
1994-12-01 13:59               ` Henry G. Baker
1994-12-02  4:26                 ` R. William Beckwith
1994-12-02 21:37               ` Hans Boehm
1994-12-03 15:17                 ` Henry G. Baker
1994-12-09 22:07                   ` Bob Duff
1994-12-11 23:59                     ` Gary McKee
1994-12-12  5:04                       ` Henry G. Baker
1994-12-12 12:46                         ` R. William Beckwith
1994-12-16 19:35                         ` Bob Duff
1994-12-17 20:36                           ` Robert Dewar
1994-12-20  5:24                           ` Henry G. Baker
1994-12-12  9:36                     ` Robb Nebbe
1994-12-13 16:12                     ` Henry G. Baker
     [not found]     ` <3be0mh$1p7@ga <3bii2g$kn2@news.parc.xerox.com>
1994-12-01  4:58       ` Kevin Warne
1994-12-02 21:58         ` Hans Boehm
     [not found] <D06r8x.JBy@inmet.camb.inmet.com>
1994-12-02 17:32 ` Henry G. Baker
1994-12-05 20:59   ` Robert Firth
1994-12-06 14:15     ` Robert Dewar
1994-12-04  1:06 ` Rick Busdiecker
1994-12-04 18:57   ` R. William Beckwith
replies disabled

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