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 Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad01.newshosting.com!newshosting.com!198.186.194.249.MISMATCH!transit3.readnews.com!news-xxxfer.readnews.com!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: Thu, 11 Feb 2010 18:08:00 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <75a9f860-ad3c-49a0-b2a1-a8f1386e6ff6@x10g2000prk.googlegroups.com> <2801be3a-afd6-4d14-ad7f-feb23a511f02@a5g2000yqi.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls6.std.com 1265929669 29170 192.74.137.71 (11 Feb 2010 23:07:49 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Thu, 11 Feb 2010 23:07:49 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:SKFmxc5vMa4t8PDM89NUUxM3PfY= Xref: g2news1.google.com comp.lang.ada:9123 Date: 2010-02-11T18:08:00-05:00 List-Id: "Hibou57 (Yannick Duch�ne)" writes: > Clarification about my words : what I've quoted from you, was talking > about extended return statement. I was understanding this as "extended > return statement applied to limited". Extended return statements are not much more than syntactic sugar. They don't change anything about when the result object is finalized. All they do is give you a name you can use to refer to the result object. If there's no name, the result object is still there, but you can't refer to it inside the function body. Oh, I guess there's one other thing extended returns do -- they allow you to default-initialize the result object: return X : T; which can't be expressed with a simple return. Extended return statements are important in the limited case, because you often want to say something like "Result.X := ...;". And as you discovered, aggregates aren't allowed for protected or task types (which was probably a language design mistake). Extended return statements are not so important for nonlimited types, but they do come in handy in that case, too. - Bob