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=-0.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,8e3b3db66f3b0061 X-Google-Attributes: gid109fba,public X-Google-Thread: fd443,8e3b3db66f3b0061 X-Google-Attributes: gidfd443,public X-Google-Thread: f4fd2,8e3b3db66f3b0061 X-Google-Attributes: gidf4fd2,public X-Google-Thread: 1014db,8e3b3db66f3b0061 X-Google-Attributes: gid1014db,public X-Google-Thread: 103376,474d28ddf953b3c1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-12-02 17:20:51 PST Newsgroups: alt.lang.design,comp.lang.c,comp.lang.c++,comp.lang.lisp,comp.lang.ada Path: bga.com!news.sprintlink.net!howland.reston.ans.net!news.moneng.mei.com!uwm.edu!lll-winken.llnl.gov!noc.near.net!inmet!dsd!bobduff From: bobduff@dsd.camb.inmet.com (Bob Duff) Subject: Re: Reference Counting (was Re: Searching Method for Incremental Garbage Collection) Message-ID: Sender: news@inmet.camb.inmet.com Organization: Intermetrics, Inc. References: <3bfprn$okr@scipio.cyberstore.ca> <3bg6ci$18k@gamma.ois.com> Date: Fri, 2 Dec 1994 23:41:54 GMT Xref: bga.com alt.lang.design:152 comp.lang.c:33113 comp.lang.c++:39346 comp.lang.lisp:4254 comp.lang.ada:8207 Date: 1994-12-02T23:41:54+00:00 List-Id: In article , Dag Bruck wrote: >>>>>> "R" == R William Beckwith 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.)