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.4 required=5.0 tests=BAYES_00,FORGED_MUA_MOZILLA autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,b9a378a9a09dab87,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.216.0.67 with SMTP id 45mr940568wea.4.1346147202493; Tue, 28 Aug 2012 02:46:42 -0700 (PDT) Path: q11ni356267657wiw.1!nntp.google.com!proxad.net!feeder1-2.proxad.net!usenet-fr.net!gegeweb.org!aioe.org!.POSTED!not-for-mail From: =?ISO-8859-15?Q?Markus_Sch=F6pflin?= Newsgroups: comp.lang.ada Subject: Access to procedure and generics Date: Tue, 28 Aug 2012 11:46:41 +0200 Organization: Aioe.org NNTP Server Message-ID: NNTP-Posting-Host: MdpKeRr+sx3LK7JQiK5aNw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20120713 Thunderbird/14.0 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Date: 2012-08-28T11:46:41+02:00 List-Id: Hello, please consider the following program. What it is trying to achieve (in Ada 95) is that a callback is registered for call as soon as the generic is instantiated. ---%<--- package CALLBACK is type CALLBACK_T is access procedure; procedure REGISTER_CALLBACK(CALLBACK : CALLBACK_T); end CALLBACK; -- package body CALLBACK is procedure REGISTER_CALLBACK(CALLBACK : CALLBACK_T) is begin null; end; end CALLBACK; -- generic package USE_CALLBACK is procedure HANDLER; end USE_CALLBACK; -- with CALLBACK; package body USE_CALLBACK is procedure HANDLER is begin null; end; begin CALLBACK.REGISTER_CALLBACK(HANDLER'Access); end USE_CALLBACK; -- with USE_CALLBACK; procedure TEST is package FOO is new USE_CALLBACK; begin null; end TEST; --->%--- When trying to compile this with GNAT 4.4.5 in Ada95 mode, I get the following error: > gnatmake -gnat95 test gcc-4.4 -c -gnat95 test.adb use_callback.adb:10:38: 'Access attribute not allowed in generic body use_callback.adb:10:38: because access type "CALLBACK_T" is declared outside generic unit (RM 3.10.2(32)) use_callback.adb:10:38: move 'Access to private part, or (Ada 2005) use anonymous access type instead of "CALLBACK_T" Now, after reading the reference cited by GNAT I think I understand why it doesn't compile, but I have a hard time figuring out what GNAT means by "move 'Access to private part". And I'm still at a loss on how to achieve what I actually need, namely automatically registering a callback as soon as the generic is instantiated. Any help would be much appreciated. Regards, Markus