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.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, INVALID_MSGID,WEIRD_PORT autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8ceb83dbf250e264 X-Google-Attributes: gid103376,public From: "Vladimir Olensky" Subject: Re: Problem with instantiating generic procedure Date: 1999/07/17 Message-ID: <932239182.670.84@news.remarQ.com>#1/1 X-Deja-AN: 502169796 References: <7mqfcq$9og$1@pegasus.csx.cam.ac.uk> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.3110.3 X-Complaints-To: newsabuse@remarQ.com X-Trace: 932239182.670.84 K3TLTKYJOA5C9C7F8C qube-02.us-ca.remarq.com Organization: Posted via RemarQ, http://www.remarQ.com - The Internet's Discussion Network NNTP-Posting-Date: Sat, 17 Jul 1999 19:19:42 GMT Newsgroups: comp.lang.ada Date: 1999-07-17T00:00:00+00:00 List-Id: Here are two working examples that solves your problem. Gnat 3.11p, WinNT. Hope this will help. As I understand it one should first have instantiation of generic procedure and only then bind it with the procedure name declared at spec. --=============================== Example 1: ---------------------------------- package Bug is procedure A; end Bug; --------------------------------- with ada.text_io; use ada.text_io; package body Bug is generic procedure G; procedure G is begin put_line("Body of A implemented as generic"); end G; procedure AA is new G; procedure A renames AA; end Bug; --=============================== Example 2: ---------------------------------- generic package G is procedure GP; end G; ---------------------------------- with ada.text_IO; use ada.text_io; package body G is procedure GP is begin put_line("Body of A implemented as generic"); end GP; end G; ----------------------- package Bug is procedure A; end Bug; ---------------- with G; package body Bug is package AA is new G; procedure A renames AA.GP; end Bug; ---------------------------- --================================== -- test procedure for both examples with Bug; procedure Tst_Bug is begin Bug.A; end Tst_Bug; ---------------------------------------------- Regards, Vladimir Olensky Markus Kuhn wrote in message <7mqfcq$9og$1@pegasus.csx.cam.ac.uk>... >Sorry, but after searching through the RM for almost an hour, I still >haven't figured out what I do wrong here and how I should fix this. >I declare in a package spec a procedure A and I want to implement the >procedure body of A by instantiating a generic procedure G. The following >is the shortest possible program that reproduces my problem: > >-- bug.ads -- >package Bug is > > procedure A; > >end Bug; >-- bug.adb -- >package body Bug is > > generic > procedure G; > > procedure G is > begin > null; > end G; > > procedure A is new G; > >end Bug; >------------- > >GNAT 3.11p on Linux insists on the following error message: > >bug.adb:1:14: missing body for "A" declared at bug.ads:3 >bug.adb:11:14: "A" conflicts with declaration at bug.ads:3 > >What is wrong with simply implementing a procedure declared >in the spec file in the body file by instantiating it from >a generic procedure of the exact same signature? Both A and G >have no parameters, so how can there be a conflict? > >It would be nice if GNAT wrote out explicitely the two conflicting >sides, each time it uses the word "conflict" in an error message. > >Any idea what is wrong here? > >Markus > >-- >Markus G. Kuhn, Computer Laboratory, University of Cambridge, UK >Email: mkuhn at acm.org, WWW: