comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Renaming primitives.
Date: Wed, 10 Jan 2024 13:13:59 +0100	[thread overview]
Message-ID: <unm1m6$2ftcd$1@dont-email.me> (raw)
In-Reply-To: <unls1j$2f0up$3@dont-email.me>

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

  parent reply	other threads:[~2024-01-10 12:13 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-10 10:37 Renaming primitives Blady
2024-01-10 11:38 ` Jeffrey R.Carter
2024-01-11 10:06   ` Blady
2024-01-11 11:06     ` Jeffrey R.Carter
2024-01-10 12:13 ` Dmitry A. Kazakov [this message]
2024-01-11  2:09   ` Randy Brukardt
2024-01-11  2:18 ` Randy Brukardt
2024-01-11 10:09   ` Blady
2024-01-12  3:59     ` Randy Brukardt
2024-01-12  9:47       ` J-P. Rosen
2024-01-12 23:36         ` Lawrence D'Oliveiro
2024-01-12 10:29       ` Blady
2024-01-12 10:42     ` Blady
replies disabled

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