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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3498dd887729ed19 X-Google-Attributes: gid103376,public From: mg@harp.camb.inmet.com (Mitch Gart) Subject: Re: Garbage Collection in Ada Date: 1996/10/31 Message-ID: #1/1 X-Deja-AN: 193406038 sender: news@inmet.camb.inmet.com (USENET news) x-nntp-posting-host: harp.camb.inmet.com references: <01bbc6a3$4cf03480$829d6482@joy.ericsson.se> organization: Intermetrics, Inc. newsgroups: comp.lang.ada Date: 1996-10-31T00:00:00+00:00 List-Id: Jonas Nygren (ehsjony@ehs.ericsson.se) wrote: (snip) : package Collected is : type Object is : tagged record : Reference_Count : Natural; : end record; : type Object_Access is access all Object'Class; : type Handle is new Ada.Finalization with : record : Ref : Object_Access; : end record; : end Collected; (snip) This suffers from several problems: - If you provide a function to do allocations, function Allocate_Obj return Handle; and users use this function, things work well, but if a user calls "new Object" directly things don't work at all. - Obj1 := Obj2; doesn't work because the reference count value is copied. If Obj2's count is 3 before the assignment, after the assignment Obj1's count is also 3 which is probably wrong. Mitch Gart