From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on ip-172-31-65-14.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00,T_SCC_BODY_TEXT_LINE, XPRIO autolearn=ham autolearn_force=no version=3.4.6 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: strange cursor in nested containers Date: Mon, 8 May 2023 22:56:30 -0500 Organization: A noiseless patient Spider Message-ID: References: <6aa39f27-62ca-4486-9fc7-1c713da5b098n@googlegroups.com> <9a1c3ba5-d5ae-41d3-9eab-2b8cd941bc66n@googlegroups.com> Injection-Date: Tue, 9 May 2023 03:56:29 -0000 (UTC) Injection-Info: dont-email.me; posting-host="36aee6c93b48d52a7a489ecbf0a77bfa"; logging-data="190261"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/JSAqt4rW68GgU6mIiQNwwXw1i2Aa8vhw=" Cancel-Lock: sha1:yXdipKPa8+VNFpTK1w9ERBgGNHs= X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.7246 X-RFC2646: Format=Flowed; Original X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-Priority: 3 Xref: news.eternal-september.org comp.lang.ada:65184 List-Id: It's not required to detect such cursors because it is expensive to do so perfectly (essentially, each cursor has to be controlled and one has to keep a list of them associated with the container). There are imperfect solutions which are likely to be "good enough" in practice, but they still have a (small) cost which may be an issue for some uses. Thus, most implementers don't use them. I know the original GNAT containers had a debugging version that included such checks, but I don't know if they still exist or how one would enable them if they do. Randy. "Mario Blunk" wrote in message news:9a1c3ba5-d5ae-41d3-9eab-2b8cd941bc66n@googlegroups.com... >> > How could I solve the problem ? Not using "rename" ? Using an aliased >> > access type as John Barnes suggests in Ada2005 on page 275 ? >> You have to avoid calling Element. Since you have a cursor, you can call >> Query_Element, which should pass the actual element to the procedure you >> supply. > > Right, that solves the problem. For those interested please find a > comparison here: > > 1. The demo with a dangling (dangerous) cursor: > https://github.com/Blunk-electronic/ada_training/blob/master/src/containers/demo/nested/nest_1.adb > > And the demo with the issue solved properly: > https://github.com/Blunk-electronic/ada_training/blob/master/src/containers/demo/nested/nest_2.adb > > Still the question remains, why such a dangling cursor is not detected at > runtime.