From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Path: eternal-september.org!reader02.eternal-september.org!aioe.org!0nYzhFpEeoH2MFWixtUlcg.user.gioia.aioe.org.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: renames usage Date: Sat, 02 Jan 2021 17:22:27 +0000 Organization: Aioe.org NNTP Server Message-ID: References: <5fedba8b$0$6186$426a74cc@news.free.fr> <5fedf478$0$21621$426a74cc@news.free.fr> <5fef180c$0$19476$426a74cc@news.free.fr> NNTP-Posting-Host: 0nYzhFpEeoH2MFWixtUlcg.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (darwin) Cancel-Lock: sha1:Fnh1HZPDtvJinN7wFLCWZavS0A8= X-Notice: Filtered by postfilter v. 0.9.2 Xref: reader02.eternal-september.org comp.lang.ada:61011 List-Id: "G.B." writes: > On 01.01.21 13:39, DrPi wrote: > >> Reading all the answers, I understand that : >>     X : Float renames Random (Seed); >> is equivalent to : >>     X : constant Float := Random (Seed); >> Right ? > > Also remember that limited types do not permit copying, > whether constant or not. Renaming avoids having to move > an object at all: Another reason for renaming, which includes the above, would be remembering a view conversion. The example to hand involves Timing_Events. The spec -- Support flashing an LED (for example, to indicate that a -- packet has been received from the controller). type Flasher (The_LED : not null access Crazyflie_LED) is tagged limited private; procedure Set (The_Flasher : in out Flasher); -- Lights the associated LED for 5 ms. In the private part type Flasher (The_LED : not null access Crazyflie_LED) is new Ada.Real_Time.Timing_Events.Timing_Event with null record; In the body protected Flasher_Handler is pragma Interrupt_Priority; procedure Turn_Off_The_LED -- the Timing_Event_Handler (Event : in out ARTTE.Timing_Event); -- We "know" that the Event is actually a Flasher. end Flasher_Handler; .. and finally protected body Flasher_Handler is procedure Turn_Off_The_LED (Event : in out ARTTE.Timing_Event) is The_Flasher : Flasher -- <<<< renames Flasher (ARTTE.Timing_Event'Class (Event)); -- <<<< begin Set (The_Flasher.The_LED.all, False); end Turn_Off_The_LED; end Flasher_Handler;