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!feeder.eternal-september.org!nntp-feed.chiark.greenend.org.uk!ewrotcd!newsfeed.xs3.de!news.jacob-sparre.dk!franka.jacob-sparre.dk!pnx.dk!.POSTED.rrsoftware.com!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Intervention needed? Date: Tue, 19 Mar 2019 17:04:22 -0500 Organization: JSA Research & Innovation Message-ID: References: <6e1977a5-701e-4b4f-a937-a1b89d9127f0@googlegroups.com> <6f9ea847-2903-48c8-9afc-930201f2765a@googlegroups.com> Injection-Date: Tue, 19 Mar 2019 22:04:23 -0000 (UTC) Injection-Info: franka.jacob-sparre.dk; posting-host="rrsoftware.com:24.196.82.226"; logging-data="10865"; mail-complaints-to="news@jacob-sparre.dk" X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Response X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 Xref: reader01.eternal-september.org comp.lang.ada:55898 Date: 2019-03-19T17:04:22-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:q6qa4u$kd0$1@gioia.aioe.org... > On 2019-03-19 03:18, Optikos wrote: >> On Monday, March 18, 2019 at 7:36:17 PM UTC-4, Randy Brukardt wrote: > >>> since the containers are designed with possibly dangling cursors, a >>> totally >>> safe system would not be usable with them. The containers do include >>> checks >>> that would detect many ownership problems, however, so any lack of >>> compile-time safety is definitely mitigated. (It's not 100% safe because >>> of >>> the possiblity that a cursor outlive the owner object; in that case, the >>> checks are unreliable.) >> >> A container could have (as a required fundamental axiom) a singly-linked >> list of spirits of all cursors ever created that reference it. As each >> cursor's life ends, that dying cursor directly knows O(1) where its >> spirit is within that linked list, and then removes its dying spirit too. >> Then as the lifetime of the container ends, the finalization of that >> linked list is to walk that link-list of spirits to abruptly undermine >> each spirit's corresponding still-living cursor so that that >> longer-lived-than-its-container cursor abruptly has the usual customary >> representation of cursor-exhausted-its-walk-of-the-container (i.e., the >> end-of-loop criterion during normal-operations' not-end-of-lifed cursor >> walks of not-end-of-lifed container), so that cursors are all instantly >> loop-terminating gracefully whenever their container ceases to exist. > > Forgive my ignorance, but how this is different from a weak reference? > >> Hence, no cursor ever contains a pointer/access/address value that out >> lives its container, because that pointer was overwritten (at container >> finalization) with the cursor-exhausted-its-walk-of-the-container >> reserved value that all loops & conditional branches interrogate as a >> matter of their normal-operations behavior. Q.E.D. > > The cursor is still dangling. The difference is that one can check if it > indeed is (with a nice race condition attached). Right. And dangling pointers are illegal in a full Rust-like scheme. So you can't declare them at all, which is a problem when you need to implement an existing specification that has them. A lot of what the ownership scheme does well isn't really necessary in Ada in the first place, as one can use a discriminant-dependent component to get the same effect without any pointers at all. I'm talking about dynamically-sized arrays and singly-linked lists (which are just sequences of elements, can be modeled as an array just as well as with a list). The more complex data strurtures seem to be very hard to build that way -- but those are the only ones really need pointers in the first place. So I'm not fully sold on the concept as the cure to all ills - it's just another tool to make code a bit safer. Randy.