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=-0.4 required=5.0 tests=AC_FROM_MANY_DOTS,BAYES_00 autolearn=no autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Formal Subprogram Access Date: Fri, 9 Feb 2018 23:11:57 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 9 Feb 2018 22:11:57 -0000 (UTC) Injection-Info: reader02.eternal-september.org; posting-host="5bd1d71638dd3344bf1d3ceb28f19f8a"; logging-data="15278"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+WMXrfwAboPowja48yTRmKxN4zByVz0kw=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 Content-Language: en-US X-Mozilla-News-Host: snews://news.eternal-september.org:563 Cancel-Lock: sha1:xbd+KSZQIOAY5EEy6Fggdd047os= Xref: reader02.eternal-september.org comp.lang.ada:50352 Date: 2018-02-09T23:11:57+01:00 List-Id: 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