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: a07f3367d7,57f8540942f8e060 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx02.iad01.newshosting.com!newshosting.com!novia!news-out.readnews.com!transit4.readnews.com!panix!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Initialization and Finalization of limited object "returned" by a function Date: Fri, 12 Feb 2010 14:11:54 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <75a9f860-ad3c-49a0-b2a1-a8f1386e6ff6@x10g2000prk.googlegroups.com> <7tkl8mF2qbU1@mid.individual.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1266001902 27800 192.74.137.71 (12 Feb 2010 19:11:42 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 12 Feb 2010 19:11:42 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:19giE2rb0KbWrxr4hrKz08LxYc0= Xref: g2news1.google.com comp.lang.ada:9184 Date: 2010-02-12T14:11:54-05:00 List-Id: Adam Beneschan writes: > But, assuming that there are no controlled components, there's nothing > preventing the compiler from generating the same code for Func1 as for > Func2, and eliminating the extra copy. So I guess that using extended > return might be worth a try---try it both ways, and see if the > compiler generates faster code. > > If there are controlled components, then the semantics are different, > because Func1 will have to assign Result to the "result > object" (requiring an "adjust" operation) and then finalize Result > (requiring a "finalize" operation). The language gives compilers > permission to remove adjust/finalize pairs in some cases, but I don't > know if this is one of those cases. I think it is. But I'm too lazy to look it up right now. If I'm right, then compilers can optimize in both controlled and non-controlled cases (for nonlimited types). >...If not, then this is a case where > extended return will definitely benefit you. - Bob