comp.lang.ada
 help / color / mirror / Atom feed
From: "G.B." <bauhaus@notmyhomepage.invalid>
Subject: Re: renames usage
Date: Sat, 2 Jan 2021 17:00:13 +0100	[thread overview]
Message-ID: <rsq5ae$1ls$1@dont-email.me> (raw)
In-Reply-To: <5fef180c$0$19476$426a74cc@news.free.fr>

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:

procedure Hammering is

    type Hammer is (Claw, Sledge);

    task type Nail is  -- A limited type
       entry Hit (Weight : Hammer);
    end Nail;

    task body Nail is separate;

    procedure Game is
       type Nail_Reference is access Nail;
       Challenge : array (1 .. 10) of Nail_Reference
         := (others => new Nail);

       function Random_Pick return Nail_Reference is
       begin
          return Challenge (2);
       end Random_Pick;

       Choice : Nail renames Random_Pick.all;
    begin
       Choice.Hit (Weight => Claw);
    end Game;

begin
    Game;
end Hammering;

  parent reply	other threads:[~2021-01-02 16:00 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-31 11:48 renames usage DrPi
2020-12-31 12:10 ` John Perry
2020-12-31 13:31   ` DrPi
2020-12-31 12:33 ` Gautier write-only address
2020-12-31 14:49 ` Jeffrey R. Carter
2020-12-31 15:55   ` DrPi
2020-12-31 18:48     ` Dmitry A. Kazakov
2021-01-01 12:39       ` DrPi
2021-01-01 13:20         ` Dmitry A. Kazakov
2021-01-02 11:53           ` DrPi
2021-01-01 14:46         ` Jeffrey R. Carter
2021-01-02 11:55           ` DrPi
2021-01-03  3:19           ` Randy Brukardt
2021-01-03 10:05             ` Jeffrey R. Carter
2021-01-06  2:49               ` Randy Brukardt
2021-01-02 16:00         ` G.B. [this message]
2021-01-02 17:22           ` Simon Wright
replies disabled

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