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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 2002:ac8:46cc:: with SMTP id h12mr10954675qto.234.1565453071115; Sat, 10 Aug 2019 09:04:31 -0700 (PDT) X-Received: by 2002:a05:6808:90d:: with SMTP id w13mr9003997oih.175.1565453070835; Sat, 10 Aug 2019 09:04:30 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!feeder.eternal-september.org!news.gegeweb.eu!gegeweb.org!usenet-fr.net!proxad.net!feeder1-2.proxad.net!209.85.160.216.MISMATCH!b26no7134284qtq.0!news-out.google.com!d29ni230qtg.1!nntp.google.com!b26no7134278qtq.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Sat, 10 Aug 2019 09:04:30 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=2a01:5c0:e08e:381:651a:54ed:c03c:131e; posting-account=3Fg1FgoAAACfsmWScNfMD1tGFhR4DU0o NNTP-Posting-Host: 2a01:5c0:e08e:381:651a:54ed:c03c:131e References: <50918b3d-cc75-4375-8735-8c007287f357@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: What is the difference? From: Gilbert Gosseyn Injection-Date: Sat, 10 Aug 2019 16:04:31 +0000 Content-Type: text/plain; charset="UTF-8" Xref: reader01.eternal-september.org comp.lang.ada:57026 Date: 2019-08-10T09:04:30-07:00 List-Id: On Saturday, August 10, 2019 at 5:24:37 PM UTC+2, Jeffrey R. Carter wrote: > On 8/10/19 3:59 PM, Gilbert Gosseyn wrote: > > > > It works in both versions. > > It doesn't work at all: > > $ cat gilbert_gosseyn.adb > procedure Gilbert_Gosseyn is > function F1 return Integer is (23); > > procedure Gg1 is new Gg (F => F1); > begin > Gg1; > end Gilbert_Gosseyn; > $ gnatmake gilbert_gosseyn.adb > x86_64-linux-gnu-gcc-8 -c gilbert_gosseyn.adb > gilbert_gosseyn.adb:4:25: "Gg" is undefined > gnatmake: "gilbert_gosseyn.adb" compilation error > > If I clean it up, it compiles (which I presume is what you mean by "work"): > > $ cat gilbert_gosseyn.adb > with G; > > procedure Gilbert_Gosseyn is > function F1 return Integer is (23); > > procedure Gg1 is new G.Gg (F => F1); > begin > Gg1; > end Gilbert_Gosseyn; > $ gnatmake gilbert_gosseyn.adb > x86_64-linux-gnu-gcc-8 -c gilbert_gosseyn.adb > x86_64-linux-gnu-gcc-8 -c g.adb > x86_64-linux-gnu-gnatbind-8 -x gilbert_gosseyn.ali > x86_64-linux-gnu-gnatlink-8 gilbert_gosseyn.ali > > > What is here the meaning of: is <>? > > It means that if there is function named F visible at the point of instantiation > with the same parameter-and-return-type profile as the formal function F, and no > actual parameter is supplied for the formal function F, then the visible > function F will be used by default: > > $ cat gilbert_gosseyn.adb > with G; > > procedure Gilbert_Gosseyn is > function F return Integer is (23); > > procedure Gg1 is new G.Gg; > begin > Gg1; > end Gilbert_Gosseyn; > $ gnatmake gilbert_gosseyn.adb > x86_64-linux-gnu-gcc-8 -c gilbert_gosseyn.adb > x86_64-linux-gnu-gnatbind-8 -x gilbert_gosseyn.ali > x86_64-linux-gnu-gnatlink-8 gilbert_gosseyn.ali > > If Gg actually uses F: > > $ cat g.adb > with Ada.Text_IO; > > package body G is > procedure Gg is > begin > Ada.Text_IO.Put_Line (Item => F'Image); > end Gg; > end G; > > then we can see that it calls the implicitly provided function F: > > $ ./gilbert_gosseyn > 23 > > -- > Jeff Carter > "I did not rob a bank. If I'd robbed a bank, everything > would be great. I tried to rob a bank, is what happened, > and they got me." > Take the Money and Run > 139 please add: with G; use G; before procedure test is