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 autolearn=ham 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!news4.google.com!feeder.news-service.com!2a02:590:1:1::196.MISMATCH!news.teledata-fn.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Thu, 14 Oct 2010 02:57:40 +0200 From: Georg Bauhaus User-Agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.11) Gecko/20101004 Thunderbird/3.1.5 MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Ada is getting more popular! References: <020ea727-e8e9-4d0d-8c5f-b8ad907fc3c9@u10g2000yqk.googlegroups.com> <0fd5e839-a2b6-41c9-b6d4-9bd4f09c044b@h7g2000yqn.googlegroups.com> In-Reply-To: <0fd5e839-a2b6-41c9-b6d4-9bd4f09c044b@h7g2000yqn.googlegroups.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4cb65584$0$6972$9b4e6d93@newsspool4.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 14 Oct 2010 02:57:41 CEST NNTP-Posting-Host: 23e9f93d.newsspool4.arcor-online.net X-Trace: DXC=dS^f4D7lO;G74okIm;?DS@4IUKejVHXW>b5>d^m5IbAf=_=8AYdM X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:15499 Date: 2010-10-14T02:57:41+02:00 List-Id: On 10/14/10 1:00 AM, ramon_garcia wrote: > It is simply that I need to perform low level tasks, such as accessing > a memory mapped file. Since you can't get a pointer to unconstrained from a constrained object(*), but you can bring data and processing subprograms together. The different solution will remove GNAT dependences. (Yes, copying might happen if an out parameter is initialized by assigning components from another array. But the scenario is different below.) Use case: If a pointer to unconstrained would be intended for obtaining access to the data array (with correct bounds), this access determines the use case, what is to be done with what. Then instead of asking for a pointer at the "client" side, invert control. Have the client provide a callback procedure that takes an unconstrained array, to be passed to the "server" side (where the data record is defined now). Either use generics or use access subprogram types (similar to updating subprograms of Ada.Containers.*). Example: -- client side: procedure Want_Bytes (Data : in out Buffer); -- perform some action on the bytes in Data -- Note: Data needs *not* be copied -- server side: generic with procedure do_something (data : in out Buffer); procedure process; -- instances will invoke do_something with a data buffer -- client side: procedure step is new Process (do_something => Want_Bytes); -- server side, body: procedure process is begin do_something (a_t.data); end process; -- client side: step; This is plain Ada and will very likely avoid copying. No pointers or aliases are needed. It's efficient, too. Extending, so as to have a container record from just anywhere, -- server side: generic with procedure do_something (data : in out Buffer); procedure Process (Info : in out Container); -- instances will invoke do_something, passing Info.data ... step (my_container_object); __ (*) http://www.adapower.com/index.php?Command=Class&ClassID=Advanced&CID=213 >> I get the impression that Mr ramon_garcia is trying to use Ada as C. >> >> Better to use Ada as Ada, makes life simpler :) >> >> --Nasser >