From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: border1.nntp.dca3.giganews.com!backlog3.nntp.dca3.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: Validity of renamed objects? Date: Tue, 01 Apr 2014 15:44:11 +0200 Organization: A noiseless patient Spider Message-ID: References: <871txhmc91.fsf@adaheads.sparre-andersen.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Injection-Date: Tue, 1 Apr 2014 13:44:11 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="23dab0694e4174fdc880833ec67fa650"; logging-data="17062"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19MdPQmdVhKR1VR6rsoGZYU" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 In-Reply-To: <871txhmc91.fsf@adaheads.sparre-andersen.dk> Cancel-Lock: sha1:GPq7/IBEFWV0baqO7VzauX3t2Pk= X-Enigmail-Version: 1.6 X-Original-Bytes: 2319 Xref: number.nntp.dca.giganews.com comp.lang.ada:185445 Date: 2014-04-01T15:44:11+02:00 List-Id: 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