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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!gandalf.srv.welterde.de!news.jacob-sparre.dk!loke.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Ada 2005,Doubly_Linked_List with Controlled parameter Date: Wed, 6 Apr 2016 15:29:38 -0500 Organization: JSA Research & Innovation Message-ID: References: <05bc57c3-9811-4248-935c-b86156298a90@googlegroups.com> <61dd12e1-4450-4c6e-b8b5-7cf1c075ebad@googlegroups.com> NNTP-Posting-Host: rrsoftware.com X-Trace: loke.gir.dk 1459974579 32635 24.196.82.226 (6 Apr 2016 20:29:39 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 6 Apr 2016 20:29:39 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 X-RFC2646: Format=Flowed; Original Xref: news.eternal-september.org comp.lang.ada:30015 Date: 2016-04-06T15:29:38-05:00 List-Id: "George J" wrote in message news:61dd12e1-4450-4c6e-b8b5-7cf1c075ebad@googlegroups.com... >> You create an aggregate of your controlled type, which is an object of >> the type. >> Append makes a copy of that object to store in the list. When you leave >> the >> procedure that did the Append, the aggregate goes out of scope and is >> finalized. >> (Presumably that leaves the copy in the list with a dangling reference.) >> >> -- >> Jeff Carter >> "Hold your temper. Count ten.... Now let 'er go. >> You got a good aim." >> Never Give a Sucker an Even Break >> 105 > > Wow,thanks,I've got! It's difficult to guess it for me. Note that you can write something like your original code, but it has to use reference counts and an overriding of Adjust in order to manage the access value properly (since the container copies the objects, and thus you have to support that). I think Christoph Grein's safe pointers give an example of how that could be done. In this case, the various alternatives suggested are better, since the compiler/runtime is doing that complicated work and you don't have to. But sometimes you need to manage an object this way, so it's valuable to know that it is possible. Randy.