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=-0.0 required=3.0 tests=BAYES_40,FREEMAIL_FROM, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Received: by 2002:a05:622a:1a90:b0:3e9:b2ec:573f with SMTP id s16-20020a05622a1a9000b003e9b2ec573fmr10499qtc.12.1681967734979; Wed, 19 Apr 2023 22:15:34 -0700 (PDT) X-Received: by 2002:a25:d604:0:b0:b96:7eae:9946 with SMTP id n4-20020a25d604000000b00b967eae9946mr247900ybg.11.1681967734698; Wed, 19 Apr 2023 22:15:34 -0700 (PDT) Path: eternal-september.org!news.eternal-september.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Wed, 19 Apr 2023 22:15:34 -0700 (PDT) In-Reply-To: Injection-Info: google-groups.googlegroups.com; posting-host=81.167.0.45; posting-account=uulyKwoAAAA86DO0ODu--rZtbje8Sytn NNTP-Posting-Host: 81.167.0.45 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <6aa39f27-62ca-4486-9fc7-1c713da5b098n@googlegroups.com> Subject: Re: strange cursor in nested containers From: Egil H H Injection-Date: Thu, 20 Apr 2023 05:15:34 +0000 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Received-Bytes: 1908 Xref: news.eternal-september.org comp.lang.ada:65117 List-Id: On Wednesday, April 19, 2023 at 9:09:48=E2=80=AFAM UTC+2, Mario Blunk wrote= : > Hello out there,=20 > I've put together a demo to reproduce a strange behavior of a cursor.=20 >=20 > https://github.com/Blunk-electronic/ada_training/blob/master/src/containe= rs/demo/nested/nest_1.adb=20 >=20 Each call to `element(n)` returns a _copy_ of the element, which in this ca= se includes the enitre doubly linked list (and since `net` is a renames of `element(n), you would have gotten multipl= e copies if you had called `net` multiple times inside query net) Using a reference instead should fix this problem: net : type_net renames nets.reference (key(n)); or (Ada 2012): net : type_net renames nets(n); --=20 ~egilhh