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.76.198 with SMTP id d6mr7452528qak.8.1359941140074; Sun, 03 Feb 2013 17:25:40 -0800 (PST) X-Received: by 10.49.15.100 with SMTP id w4mr1631199qec.26.1359941140052; Sun, 03 Feb 2013 17:25:40 -0800 (PST) Path: k2ni4456qap.0!nntp.google.com!p13no8357101qai.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sun, 3 Feb 2013 17:25:39 -0800 (PST) In-Reply-To: <85ip696nlk.fsf@stephe-leake.org> 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> <85ip696nlk.fsf@stephe-leake.org> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8d39b2ad-dc6c-4492-bc43-d2d01d748efa@googlegroups.com> Subject: Re: Passing indefinite types From: sbelmont700@gmail.com Injection-Date: Mon, 04 Feb 2013 01:25:40 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2013-02-03T17:25:39-08:00 List-Id: On Sunday, February 3, 2013 5:26:15 PM UTC-5, Stephen Leake wrote: >=20 > Could you show some almost legal code? >=20 I have found several occasions where this is useful (mostly for dealing wit= h classwide types in constructing functions), but for an example consider s= omething more straightforward: Suppose you want to write a subprogram that= searches for a string pattern within an unconstrained number of other stri= ngs (and also suppose for the sake of argument that you cannot implement it= as multiple calls to a subprogram that searches within a single string). = Since you can't have "ragged" arrays of indefinite types, you try an array = of pointers: package k type p is access all string; type a is array (positive range <>) of p; function find (p: string, sources : a) return boolean; end k; But you can't ever call this from a subprogram with locally declared string= s, since trying to create p.a with local strings fails the accessibility ch= eck. You can use heap values or unchecked_access, but that's ugly and ough= t to be unecessary, since the subprogram is not doing anything sketchy with= the values. You can't have an unconstrained number of access discriminants (or access p= arameters), and trying to 'wrap' each local value fails as well: package k type p (s : access string) is null record; type a is array (positive range <>) of p; --illegal! function find (p: string, sources : a) return boolean; end k; This is the most aggrevating, because p (in this case) is not actually inde= finite, and is always a single, fixed-size (coextensions notwithstanding, b= ut I don't dare look down that rabbit hole). Even when the number is fixed, but sufficiently large, normal parameters ar= e unwieldly. For instance: function find (p: string, source1 : string; source2 : string; source451 : string) return boolean; =20 >=20 > I wonder if it would be possible to write an aspect or other constraint >=20 > that asserts "no pointers are copied"? >=20 That's what access discriminats (and to a lesser extent, access parameters)= usually work well for, but I suppose there is no way to create an unconstr= ained number of them. What I would like to see is an aspect that says "thi= s discriminated record is not going to be variant, so it's okay to nest it = within records and arrays", so that arrays of 'accessors' are legal. Thank you (everyone) for the responses. -sb