From mboxrd@z Thu Jan 1 00:00:00 1970 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Blady Newsgroups: comp.lang.ada Subject: Re: Renaming primitives. Date: Thu, 11 Jan 2024 11:06:45 +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: Thu, 11 Jan 2024 10:06:47 -0000 (UTC) Injection-Info: dont-email.me; posting-host="3c51d50ffdb2a9483b64bc8ff7220ce6"; logging-data="3107590"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18iRy5drLnff1W0OI9i+vk5" User-Agent: Mozilla Thunderbird Cancel-Lock: sha1:A+pCaQsizfFIFtwGFlUD/Gm3ito= In-Reply-To: Content-Language: fr, en-US Xref: news.eternal-september.org comp.lang.ada:65983 List-Id: Le 10/01/2024 à 12:38, Jeffrey R.Carter a écrit : > On 2024-01-10 11:37, Blady wrote: >>     procedure My_Log_3 (Msg : String) renames My_Generic_Handler.Log; > > My_Generic_Handler.Log is shorthand for My_Generic_Handler.all.Log. > According to AARM 8.5.4(5.e/5) > (http://www.ada-auth.org/standards/22aarm/html/AA-8-5-4.html), the > renaming also renames the prefixing object and passes it to calls to the > renamed subprogram: "The prefix in such a case is essentially renamed > and passed to any calls of the renamed subprogram." > > So if I understand this correctly the renaming is roughly equivalent to > > : Loggings.Logging renames My_Generic_Handler.all; > procedure My_Log_3 (Handler : Loggings.Logging := ; Msg : > String) renames Loggings.Logging.Log; > > except that My_Log_3 is called with only a String parameter even when > using positional notation. > > Another way to look at it is that > >    My_Log_3 ("msg"); > > is implemented as > >    .Log (Msg => "msg"); Thanks for your useful explanation. > > What is happening if My_Generic_Handler change? > > >>        type Full_Logging is new Logging with null record; >>        procedure Log (Handler : Full_Logging; Msg : String); >> ... >>     My_Full_Handler : aliased Loggings.Full_Logging := (Output => >> Ada.Text_IO.Current_Output); >> ... >>     My_Generic_Handler := My_Full_Handler'Access; >> >> Well, logically (?), My_Log_3 follows the change and outputs with >> Full_Logging. > > No, My_Log_3 continues to call Log with My_Handler as the object, IIUC. Yet, the code: My_Log_3 ("Hei"); My_Generic_Handler := My_Full_Handler'Access; My_Log_3 ("Hei"); gives: Hei Full Hei I thought that was correct, wasn't it? Pascal.