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-Thread: 103376,5dacec64c8c879fa X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.226.10 with SMTP id ro10mr2605487pbc.6.1328836107171; Thu, 09 Feb 2012 17:08:27 -0800 (PST) MIME-Version: 1.0 Path: wr5ni6821pbc.0!nntp.google.com!news2.google.com!goblin3!goblin2!goblin.stu.neva.ru!weretis.net!feeder4.news.weretis.net!nuzba.szn.dk!news.jacob-sparre.dk!pnx.dk!jacob-sparre.dk!ada-dk.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Preventing Unchecked_Deallocation? Date: Thu, 9 Feb 2012 19:08:20 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <33a35da4-6c3e-4ab4-b58f-a9d73565d79a@t30g2000vbx.googlegroups.com><4350713b-6ac3-4b22-b221-8da2bac52fea@t5g2000yqk.googlegroups.com><26e4f2a4-edae-4e37-8697-f2390e636a21@z31g2000vbt.googlegroups.com> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1328836105 16920 69.95.181.76 (10 Feb 2012 01:08:25 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 10 Feb 2012 01:08:25 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2012-02-09T19:08:20-06:00 List-Id: "Simon Wright" wrote in message news:m2lioc4fu9.fsf@pushface.org... > "Randy Brukardt" writes: > >> If you don't need (visible) dereferences at all, you should definitely >> use a handle type like the Cursor type of Ada Containers. Indeed, I >> think that the vast majority of the time, you should simply use the >> Cursor type directly (putting the objects into appropriate instances >> of the containers). There you don't have any visible access types (and >> any existence of them is easily detected with tools, see below). > > If you mean that the link from object A to object B should be a Cursor > to the Container with the B's in it, will that Cursor retain its > validity if I update the B Container? (by, say, adding another B). Yes, of course, that's required by the definition of cursors (for instance, see A.18.3(2/2) for the linked list container). It does become "invalid" if the B is points at is deleted (in which case it points to nothing, of course) or if the entire container is finalized (again, it points to nothing). Using "invalid" cursors is a bounded error in most circumstances; one would hope that most containers catch it (and raise Program_Error) but it's not required (making the pointerness visible again, unfortunately). One reason that's it's not required is that it isn't reasonable to detect cursors that point at destroyed containers - the memory might be deallocated and reused, and once that happens, checks are unreliable. It would be possible (in a custom container) to prevent all dangling cursors, but it would require making cursors controlled and keeping track of all of them in the container (so if the container changes, it can search out any dead cursors and invalidate them). The id matching check that Janus/Ada uses catches about 99% of dangling cursors and is far cheaper -- but if you need a guarentee, even that is possible. Randy. Randy.