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=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI autolearn=unavailable autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8a6e6d9458ae6ddc X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!proxad.net!usenet-fr.net!enst.fr!melchior!cuivre.fr.eu.org!melchior.frmug.org!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Is this a bug? Date: 23 Sep 2004 20:28:13 -0400 Organization: Cuivre, Argent, Or Message-ID: References: <5ad0dd8a.0409221652.6a69b336@posting.google.com> <5ad0dd8a.0409230035.337f9305@posting.google.com> <2rg6a1F1arg02U1@uni-berlin.de> NNTP-Posting-Host: lovelace.ada-france.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: melchior.cuivre.fr.eu.org 1095985704 22793 212.85.156.195 (24 Sep 2004 00:28:24 GMT) X-Complaints-To: usenet@melchior.cuivre.fr.eu.org NNTP-Posting-Date: Fri, 24 Sep 2004 00:28:24 +0000 (UTC) To: comp.lang.ada@ada-france.org Return-Path: In-Reply-To: User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3 X-Virus-Scanned: by amavisd-new-20030616-p10 (Debian) at ada-france.org X-BeenThere: comp.lang.ada@ada-france.org X-Mailman-Version: 2.1.4 Precedence: list List-Id: "Gateway to the comp.lang.ada Usenet newsgroup" List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Xref: g2news1.google.com comp.lang.ada:4064 Date: 2004-09-23T20:28:13-04:00 Brian May writes: > So another words, if I did the following: > > declare > ... > Current : Bucket_Access renames Current_Hook.all; > > begin > ... > Current_Hook := > ... > end; > > > Then Current would still be the same object and value it use to be? Yes, you have it right. > If so, then "renames" isn't quite as simple as I thought. You are not alone; it seems to be a common misunderstanding for people learning Ada. > It is more like a "hard link" then a "symbolic link". i.e. it links > to the object rather then the name of the object. Interesting. The purpose of "renames" is to cache the results of computing a complex name. Although sometimes we think of it as just "cleaning up the code", it can produce significant time and code space optimization. If you want a short name for a complex expression, that is re-evaluated each time the name is used, you need a function, not a rename: declare function Current is return Current_Hook.all; end Current; begin Only 3 more identifiers! > Question: If you freed the value (with unchecked_deallocate) of > "Current_Hook" would the value of "Current" still be valid? I > suspect it would not be valid, as "Current" is now dangling. Current would be invalid. -- -- Stephe