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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.42.196.68 with SMTP id ef4mr1782169icb.18.1386360458730; Fri, 06 Dec 2013 12:07:38 -0800 (PST) X-Received: by 10.50.82.33 with SMTP id f1mr95486igy.0.1386360458531; Fri, 06 Dec 2013 12:07:38 -0800 (PST) Path: backlog2.nntp.dca3.giganews.com!backlog2.nntp.ams2.giganews.com!border1.nntp.ams2.giganews.com!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!feeds.phibee-telecom.net!feeder.erje.net!us.feeder.erje.net!news.glorb.com!news-out.readnews.com!news-xxxfer.readnews.com!209.85.216.88.MISMATCH!p15no8516543qaj.0!news-out.google.com!p7ni11420qat.0!nntp.google.com!bm17no16847624qab.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 6 Dec 2013 12:07:38 -0800 (PST) In-Reply-To: <52a218e1$0$9512$9b4e6d93@newsspool1.arcor-online.net> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=KSa2aQoAAACOxnC0usBJYX8NE3x3a1Xq NNTP-Posting-Host: 66.126.103.122 References: <52a218e1$0$9512$9b4e6d93@newsspool1.arcor-online.net> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <3ab85539-9683-46f0-bce8-b445282c68b2@googlegroups.com> Subject: Re: Renaming vs assignment to constant From: adambeneschan@gmail.com Injection-Date: Fri, 06 Dec 2013 20:07:38 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: number.nntp.dca.giganews.com comp.lang.ada:184113 Date: 2013-12-06T12:07:38-08:00 List-Id: On Friday, December 6, 2013 10:35:12 AM UTC-8, G.B. wrote: > Generated code is (or was) more efficient for arrays because the array=20 > object renamed isn't (or wasn't) copied into the constant. Definitely not necessarily true for Ada 2012; 7.6(17.1-17.4) specify that t= he object may be built in place, without an copying. Build-in-place is req= uired for some types, and allowed for all others. For the cases where it's= not required, renaming could be more efficient depending on the compiler i= mplementation. Prior to Ada 2012, I don't think this was necessarily true either, where no= controlled types are involved. The language semantics do say that a funct= ion result is stored in an anonymous object, and then the constant is creat= ed and the anonymous object assigned into it. But the language semantics o= nly tell you what effect a program is supposed to have, not what the genera= ted instructions are supposed to look like. So if a copy is a straight blo= ck copy that would do nothing but waste time, nothing in the RM requires th= e program to have instructions that put the data in a different place and t= hen copy it. (There may be an obscure case where it would make a differenc= e, i.e. if the object being built has a "for Obj'Address use..." clause and= the function has an extended return and an exception is raised during the = extended return.) But when controlled types are involved, there were cases= where a rename would be more efficient, prior to Ada 2012. -- Adam