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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a41c4a2c795dbe34 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!f31g2000pri.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: Will "renames" increase program size? Date: Thu, 16 Jun 2011 08:40:41 -0700 (PDT) Organization: http://groups.google.com Message-ID: <2e8222df-9b82-497f-9dc4-5cb0d5653550@f31g2000pri.googlegroups.com> References: <46294109-f07d-49c0-8e81-65a369a05ced@z15g2000prn.googlegroups.com> <1ayjsy885qg2b$.13bmeo97hbau1$.dlg@40tude.net> <316ac8ed-1ded-43d0-98d1-36bb2c0221ad@f2g2000yqh.googlegroups.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1308238992 17406 127.0.0.1 (16 Jun 2011 15:43:12 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 16 Jun 2011 15:43:12 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: f31g2000pri.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: ARLUEHNKC X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1; .NET CLR 2.0.50727; Media Center PC 5.0; .NET CLR 3.5.21022; .NET CLR 3.5.30729; .NET CLR 3.0.30618; .NET4.0C),gzip(gfe) Xref: g2news2.google.com comp.lang.ada:20845 Date: 2011-06-16T08:40:41-07:00 List-Id: On Jun 16, 1:59=A0am, "Dmitry A. Kazakov" wrote: > > > That's not correct. A renaming does not copy nor somehow create new > > entities, it only creates new names for the same thing. Since > > visibility is via names, you arrive at unresolvability issues. > > No. First, sometimes it certainly copies, e.g. when the function's result > is renamed, the result (temporary object) is copied. The compiler might > optimize the temporary object away, or even mandated to do so for limited > results, but *semantically* it is a copy. I don't think that's right. The test would be: type T1 is new Ada.Finalization.Controlled with record F1 : Integer; end record; overriding procedure Adjust (Obj : in out T1); function Func (N : Integer) return T1 is begin return Ret : T1 do T1.F1 :=3D N; end return; end Func; procedure Proc is R : T1 renames Func(3); begin ... end Proc; In this example, I believe that the renaming declaration cannot legally cause Adjust to be called. (This is in contrast with R : T1 :=3D Func(3); in which case the semantics specify that Adjust should be called, but I think there are implementation permissions that would allow the compiler to optimize the Adjust away.) In the renaming case, as I read the RM, the extended return creates a return object, the function call denotes a constant view of the return object, and the renaming denotes a new view of the return object. There's no copying or assignment involved. (Of course, the compiler could generate some sort of block-copy to implement this, but I think we're talking about Ada semantics. I don't think our compiler generates a block copy.) -- Adam