From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: What is the difference?
Date: Sat, 10 Aug 2019 17:24:35 +0200
Date: 2019-08-10T17:24:35+02:00 [thread overview]
Message-ID: <qimnjj$l52$1@dont-email.me> (raw)
In-Reply-To: <50918b3d-cc75-4375-8735-8c007287f357@googlegroups.com>
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
next prev parent reply other threads:[~2019-08-10 15:24 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 [this message]
2019-08-10 16:04 ` Gilbert Gosseyn
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