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=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: What is the difference? Date: Sat, 10 Aug 2019 17:24:35 +0200 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <50918b3d-cc75-4375-8735-8c007287f357@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Sat, 10 Aug 2019 15:24:36 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="3c063f6ba55ffcd3718eb9a28536f538"; logging-data="21666"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/G+FOAPrVXST72dxvkDqFRgmv2vPo8NH0=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 Cancel-Lock: sha1:fF8tlB+Zq8EUH8oy0nrBlbd5K/Q= In-Reply-To: <50918b3d-cc75-4375-8735-8c007287f357@googlegroups.com> Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:57025 Date: 2019-08-10T17:24:35+02:00 List-Id: 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