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=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,e276c1ed16429c03 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!u10g2000yqk.googlegroups.com!not-for-mail From: ramon_garcia Newsgroups: comp.lang.ada Subject: Re: Ada is getting more popular! Date: Wed, 13 Oct 2010 14:53:14 -0700 (PDT) Organization: http://groups.google.com Message-ID: <020ea727-e8e9-4d0d-8c5f-b8ad907fc3c9@u10g2000yqk.googlegroups.com> References: NNTP-Posting-Host: 88.84.91.37 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1287006800 22123 127.0.0.1 (13 Oct 2010 21:53:20 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Wed, 13 Oct 2010 21:53:20 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: u10g2000yqk.googlegroups.com; posting-host=88.84.91.37; posting-account=MJRf0QoAAAD4D6NLVoX5XW3Tna9p9iQ7 User-Agent: G2/1.0 X-HTTP-Via: 1.1 DAVINCI3 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; es-ES; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:15489 Date: 2010-10-13T14:53:14-07:00 List-Id: > If you think you need to rely on this, it is extremely likely that there is > something you don't understand. > I have a record with an array member constrained. I want to obtain an unconstrained accesss, because I want to return it in a procedure. I want to return an access, because returning an array implies a copy. And I want the caller to get the bounds of the returned access at runtime. type buffer is array(Natural range<>) of Unsigned_8; type buffer_access is access all buffer; type t is record data: buffer(1..4); end record; a_t: t := .....; abuf_access := a_t.data'Unrestricted_Access; Note that this has two dependencies with GNAT: - Access to arrays use double pointers. So in the obtained access one can obtain the bounds correctly, with abuf_access'First, abuf_access'Last. - The attribute Unrestricted_Access. I cannot understand why a procedure that expects an unconstrained array can be passed a constrained one, and it is not possible to get an access to an unconstrained array from a constrained one.