From: "J-P. Rosen" <rosen@adalog.fr>
Subject: Re: Validity of renamed objects?
Date: Tue, 01 Apr 2014 15:44:11 +0200
Date: 2014-04-01T15:44:11+02:00 [thread overview]
Message-ID: <lhefrb$gl6$1@dont-email.me> (raw)
In-Reply-To: <871txhmc91.fsf@adaheads.sparre-andersen.dk>
Le 01/04/2014 15:04, Jacob Sparre Andersen a écrit :
> I've been reading section 8.5.1 in the LRM, and I can't figure out when
> the compiler is supposed to check the validity of a renamed object.
>
> An example:
>
> procedure Renaming_1 is
> Object : String (1 .. 9) := "dead beef";
> Index : Natural := 0;
> Renamed : Character renames Object (Index);
> begin
> Index := (Object'First + Object'Last) / 2;
> if Renamed /= ' ' then
> raise Program_Error
> with "Expected Renamed to match the changed value of Index.";
> end if;
> end Renaming_1;
>
> 1) Should I get a Constraint_Error when Renamed is declared?
Yes
> 2) What will the value of Renamed be after Index has been changed?
>
Assuming Index is 1 (in order to avoid Constraint_Error), Renamed is
unchanged.
The principle is that when you elaborate the renaming declaration, you
evaluate the renamed object, and from then on the renaming identifier
designates that object. It's not a macro!
--
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr
next prev parent reply other threads:[~2014-04-01 13:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-01 13:04 Validity of renamed objects? Jacob Sparre Andersen
2014-04-01 13:44 ` J-P. Rosen [this message]
2014-04-01 13:55 ` Markus Schöpflin
2014-04-01 18:35 ` Jacob Sparre Andersen
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox