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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,19140af19dfa6e01 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-09-14 12:26:19 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!newshub.sdsu.edu!elnk-nf2-pas!newsfeed.earthlink.net!stamper.news.pas.earthlink.net!stamper.news.atl.earthlink.net!newsread2.news.atl.earthlink.net.POSTED!not-for-mail Sender: mheaney@MHEANEYX200 Newsgroups: comp.lang.ada Subject: Re: Ada 0Y plans for garbage collection? References: <1127954.kcBZz6amlf@linux1.krischik.com> <3F60E747.40805@attbi.com> <1557617.vUiuI5kIPQ@linux1.krischik.com> From: Matthew Heaney Message-ID: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Sun, 14 Sep 2003 19:26:19 GMT NNTP-Posting-Host: 65.110.133.134 X-Complaints-To: abuse@earthlink.net X-Trace: newsread2.news.atl.earthlink.net 1063567579 65.110.133.134 (Sun, 14 Sep 2003 15:26:19 EDT) NNTP-Posting-Date: Sun, 14 Sep 2003 15:26:19 EDT Organization: EarthLink Inc. -- http://www.EarthLink.net Xref: archiver1.google.com comp.lang.ada:42486 Date: 2003-09-14T19:26:19+00:00 List-Id: Martin Krischik writes: > I agree with you on that one. A reference counting access type would be as > good a real garbage collector. If you need a reference-counted pointer, then just build one. Something like: package P is type T (<>) is limited private; type T_Access is access all T; type Handle_Type is private; function New_T return Handle_Type; function "+" (Handle : Handle_Type) return T_Access; procedure Op (O : access T); ... end P; Now you can do this: declare O : Handle_Type := New_T; begin Op (+O); end; --automatically deallocates object The only problem with this schema is that it's still possible for a client to use "+" to get the internal access type, and then hold on to it. I pitched the idea to have an access types with a partial view, like this: package P is type T (<>) is limited private; type T_Access (<>) is limited access all T with private; Now this limits what you can do with the value returned by "+"; for example, you wouldn't be able to make a copy of it. However, there didn't seem to be much enthusiasm for such a language change. Actually, if you don't need dispatching, then you could do this already: package P is type T (<>) is limited private; type T_Access (<>) is limited private; procedure Op (O : T_Access); ... private type T_Access is access all T; end P;