comp.lang.ada
 help / color / mirror / Atom feed
From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Formal Subprogram Access
Date: Fri, 9 Feb 2018 23:11:57 +0100
Date: 2018-02-09T23:11:57+01:00	[thread overview]
Message-ID: <p5l6bd$ete$1@dont-email.me> (raw)

Suppose I have something like

procedure Fpa_Proc (P : not null access procedure) is
    -- Empty
begin -- Fpa_Proc
    null;
end Fpa_Proc;

generic -- Fpa_Gen
    with procedure P;
procedure Fpa_Gen;

with Fpa_Proc;

procedure Fpa_Gen is
    -- Empty
begin -- Fpa_Gen
    Fpa_Proc (P => P'Access);
end Fpa_Gen;

(FPA for Formal Procedure Access)

FSF GNAT 7.2.0 rejects Fpa_Gen with the error

fpa_gen.adb:6:19: not subtype conformant with declaration at fpa_proc.adb:1
fpa_gen.adb:6:19: formal subprograms not allowed

which I think is correct. I can change it to have a wrapper procedure:

with Fpa_Proc;

procedure Fpa_Gen is
    procedure New_P is
       -- Empty
    begin -- New_P
       P;
    end New_P;
begin -- Fpa_Gen
    Fpa_Proc (P => New_P'Access);
end Fpa_Gen;

which compiles fine. But to my surprise, I can also rename P:

with Fpa_Proc;

procedure Fpa_Gen is
    procedure New_P renames P;
begin -- Fpa_Gen
    Fpa_Proc (P => New_P'Access);
end Fpa_Gen;

and this also compiles. I would think that if you can't take 'Access of a 
generic formal subprogram, then you shouldn't be able to take 'Access of a 
renaming of a generic formal subprogram. So I'm wondering if this last form is 
legal.

-- 
Jeff Carter
"Gentlemen, you can't fight in here. This is the War Room!"
Dr. Strangelove
30


             reply	other threads:[~2018-02-09 22:11 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-09 22:11 Jeffrey R. Carter [this message]
2018-02-10  3:03 ` Formal Subprogram Access Randy Brukardt
2018-02-10  9:57   ` Jeffrey R. Carter
2018-02-13  5:51     ` Randy Brukardt
2018-02-13  9:24       ` AdaMagica
2018-02-13  9:41         ` Dmitry A. Kazakov
2018-02-13 10:28           ` AdaMagica
2018-02-14  0:47             ` Randy Brukardt
2018-02-14  8:19               ` Dmitry A. Kazakov
2018-02-14 10:01                 ` Jacob Sparre Andersen
2018-02-14 11:07                   ` Dmitry A. Kazakov
2018-02-13 12:24       ` Simon Wright
2018-02-14  0:53         ` Randy Brukardt
2018-02-14 14:36           ` Simon Wright
2018-02-15  4:56             ` Randy Brukardt
2018-02-15 13:12               ` Simon Clubley
2018-02-15 16:38                 ` Simon Wright
2018-02-15 18:40                   ` Simon Clubley
2018-02-15 16:19               ` Simon Wright
2018-02-15 23:03               ` Randy Brukardt
2018-02-13 17:34       ` Jeffrey R. Carter
2018-02-13 18:31         ` AdaMagica
2018-02-14  0:57           ` Randy Brukardt
2018-02-10 14:55   ` AdaMagica
2018-02-21 17:51 ` Jeffrey R. Carter
replies disabled

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