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.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,ebdc5ed511896a0 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!inka.de!rz.uni-karlsruhe.de!news.belwue.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: urgent question - generics Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1188809249.040351.100160@r29g2000hsg.googlegroups.com> <46DBD07D.1010608@obry.net> <1188811690.972176.242330@22g2000hsm.googlegroups.com> <46DC0F26.8090804@obry.net> <46dc14fb$0$3230$39db0f71@news.song.fi> Date: Mon, 3 Sep 2007 17:01:14 +0200 Message-ID: NNTP-Posting-Date: 03 Sep 2007 17:00:50 CEST NNTP-Posting-Host: daecc017.newsspool1.arcor-online.net X-Trace: DXC=ZT8T@h;NIOZU6b:FjPaGjQic==]BZ:af^4Fo<]lROoRQ4nDHegD_]RUGMUfi@UE\>VDNcfSJ;bb[UIRnRBaCd8b[HYg\JfRcE^Bi6bX X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:1698 Date: 2007-09-03T17:00:50+02:00 List-Id: On Mon, 03 Sep 2007 17:08:28 +0300, Niklas Holsti wrote: > It's still unclear to me if the OP wants the parameterless > procedure (Proc, above) to be a generic parameter (as in Pascal's > solution) that is associated with an actual procedure when the > generic function is instantiated, or a non-generic parameter to the > (generic) function that is associated with an actual procedure when > an instance of the generic function is called (as in "anon's" > non-generic solution where only the address of the procedure was used). I doubt that the exercise would use the word "generic" in this case. Just: function Bar (...; Foo : access procedure) return ...; -- Ada 2005 type Foo_Ptr is access procedure; function Bar (...; Foo : Foo_Ptr) return ...; -- Ada 95 But OK, in order to add a bit more confusion (:-)), there also could be a generic function which formal generic parameter is an instance of a generic parameterless procedure. Here it goes: generic ... package I_Have_A_Foo is -- We need an envelope package procedure Foo; end I_Have_A_Foo; generic with package Here_Is_My_Foo is new I_Have_A_Foo (<>); function Bar (...) return ...; Moreover, there could be a generic function which formal generic parameter is inherited from a generic ancestor: generic with procedure Foo; package I_Take_Foo is ... end I_Take_Foo; generic function I_Take_Foo.Bar (...) return ...; Being a child of I_Take_Foo, Bar receives Foo from its parent. I hope that would suffice to perplex the prof... (:-)) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de