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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,3ebfb7ec7bfb06fa X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit X-Received: by 10.224.190.193 with SMTP id dj1mr13969226qab.6.1360098970589; Tue, 05 Feb 2013 13:16:10 -0800 (PST) X-Received: by 10.49.1.70 with SMTP id 6mr2273802qek.27.1360098970571; Tue, 05 Feb 2013 13:16:10 -0800 (PST) Path: k2ni8440qap.0!nntp.google.com!p13no13633774qai.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Tue, 5 Feb 2013 13:16:10 -0800 (PST) In-Reply-To: <5262a822-409a-4c79-a842-0e716527cb70@googlegroups.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=206.53.78.59; posting-account=ShYTIAoAAABytvcS76ZrG9GdaV-nXYKy NNTP-Posting-Host: 206.53.78.59 References: <5262a822-409a-4c79-a842-0e716527cb70@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <1012259e-1325-4121-ac43-c17e5a17d0b9@googlegroups.com> Subject: Re: Passing indefinite types From: sbelmont700@gmail.com Injection-Date: Tue, 05 Feb 2013 21:16:10 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2013-02-05T13:16:10-08:00 List-Id: I had pretty much resigned myself to using the heap anyhow, this was mostly= just out of curiosity as to whether it could be done or not. It seems a s= hame that it cannot, since there are already mechanisms to safely pass loca= l access values to longer-lived subprograms, so long as their are by themse= lves or within records. An array seems like the logical next step. But in the interests of proving it can actually be done, here is my best ta= ke on it: a (completly unreadable) linked list of access-discriminanted rec= ords, where the callee would presumably iterate through them as needed. Th= is would work for limited types, too, whereas (most of?) the normal contain= ers would not. package k is type String_Holder (s : not null access string) is null record; =20 type Node; type Node_Holder (n : not null access Node) is null record; type Node (string_data : not null access String_Holder; next_node : access Node_Holder) is null record; =20 function find (pattern : string; sources : Node) return boolean; =20 end k; procedure p is s1 : aliased string :=3D "One thing"; s2 : aliased string :=3D "another thing"; s3 : aliased string :=3D "third thing"; =20 s1_h : aliased k.string_holder :=3D (s =3D> s1'access); s2_h : aliased k.string_holder :=3D (s =3D> s2'access); s3_h : aliased k.string_holder :=3D (s =3D> s3'access); n3 : aliased k.node :=3D (s3_h'access, null); n3_h : aliased k.node_holder :=3D (n =3D> n3'access); =20 n2 : aliased k.node :=3D (s2_h'access, n3_h'access); n2_h : aliased k.node_holder :=3D (n =3D> n2'access); =20 n1 : k.node :=3D (s1_h'access, n2_h'access); =20 x : boolean :=3D k.find ("look ma, no heap!", n1); begin null; end; Thanks again to everyone for their suggestions. -sb