comp.lang.ada
 help / color / mirror / Atom feed
From: Gilbert Gosseyn <hnptz@yahoo.de>
Subject: Re: What is the difference?
Date: Sat, 10 Aug 2019 09:04:30 -0700 (PDT)
Date: 2019-08-10T09:04:30-07:00	[thread overview]
Message-ID: <c015a95e-e78d-4b90-af8f-b2957cfd2ea8@googlegroups.com> (raw)
In-Reply-To: <qimnjj$l52$1@dont-email.me>

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


  reply	other threads:[~2019-08-10 16:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-10 13:59 What is the difference? Gilbert Gosseyn
2019-08-10 15:24 ` Jeffrey R. Carter
2019-08-10 16:04   ` Gilbert Gosseyn [this message]
2019-08-12 13:44 ` Shark8
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox