From mboxrd@z Thu Jan 1 00:00:00 1970 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Renaming primitives. Date: Wed, 10 Jan 2024 13:13:59 +0100 Organization: A noiseless patient Spider Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Date: Wed, 10 Jan 2024 12:13:58 -0000 (UTC) Injection-Info: dont-email.me; posting-host="3ec672b6e3be53c27e243d9bd8b20266"; logging-data="2618765"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18ZGrQcQbOERYqi2Qrqdu95ODkhGmkftU4=" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:1d1HNsPRF8B/1M1bATq/w1yOwLE= Content-Language: en-US In-Reply-To: Xref: news.eternal-september.org comp.lang.ada:65979 List-Id: On 2024-01-10 11:37, Blady wrote: > Is a procedure renaming equivalent to a simple call? > For instance: >    procedure Log (Msg : String) is >    begin >       Ada.Text_IO.Put_Line (Msg); >    end Log; >    procedure My_Log_1 (Msg : String) is >    begin >       Log (Msg); >    end My_Log_1; >    procedure My_Log_2 (Msg : String) renames Log; > > Almost, My_Log_1 is equivalent to My_Log_2, isn't it? > > Is it the same with primitives? > > For instance: >    package Loggings is >       type Logging is tagged record >          Output : Ada.Text_IO.File_Access; >       end record; >       procedure Log (Handler : Logging; Msg : String); >    end Loggings; >    My_Handler : aliased Loggings.Logging := (Output => > Ada.Text_IO.Current_Output); >    My_Generic_Handler : access Loggings.Logging'Class := > My_Handler'Access; >    procedure My_Log_3 (Msg : String) renames My_Generic_Handler.Log; > > To my surprise (well I hoped) My_Log_3 is compiled by GNAT. > Is it conformed to the Ada standard? This looks like a bug to me. ARM 8.5.4 (2/3) states that the right part of "renames" must be a name of a callable entity. My_Generic_Handler.Log is a procedure call which is not a callable entity name. Renaming a callable result of a function call might be legal [and quite funny]. Disclaimer. I am not a language lawyer. P.S. Specialization of subprograms would be a nice feature, though. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de