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,e51f94f876618e37 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.180.98.138 with SMTP id ei10mr873213wib.4.1353058408293; Fri, 16 Nov 2012 01:33:28 -0800 (PST) Path: ha8ni292961wib.1!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!193.141.40.65.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!border2.nntp.ams2.giganews.com!border4.nntp.ams.giganews.com!border2.nntp.ams.giganews.com!border2.nntp.dca.giganews.com!border3.nntp.dca.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!novia!news-hub.siol.net!news1.t-com.hr!newsfeed.CARNet.hr!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Bill Findlay Newsgroups: comp.lang.ada Subject: Re: Question[s] about aliased extended return. Date: Sat, 10 Nov 2012 10:59:31 +0000 Message-ID: References: <9bbd99bd-f953-434d-b3c8-6e8a6d5c7dfd@googlegroups.com> <3f8ba99f-015f-4567-8d31-6c711beb58c4@googlegroups.com> Mime-Version: 1.0 X-Trace: individual.net CuQIMMHMAmH9fQWJcwC0PgZWyFab+aS/YsvWghZeY/9QWbGs2v2cslKqbIECQ7/r0w Cancel-Lock: sha1:lLO5q5E8jR/+VgQZlTPnWOgr+7M= User-Agent: Microsoft-Entourage/12.33.0.120411 Thread-Topic: Question[s] about aliased extended return. Thread-Index: Ac2/MnXY3veqKr8k3EOAGKZBjkcAHg== Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Date: 2012-11-10T10:59:31+00:00 List-Id: On 10/11/2012 01:52, in article 3f8ba99f-015f-4567-8d31-6c711beb58c4@googlegroups.com, "Shark8" wrote: > On Friday, November 9, 2012 6:08:46 PM UTC-7, Jeffrey Carter wrote: >> On 11/09/2012 12:42 PM, Shark8 wrote: >> >> The extended return exists for build-in-place results of limited types. >> There's >> really no reason to use it for other types. > > Really? I thought it was quite useful for initializing things too: > > Type Matrix is Array(Positive Range <>, Positive Range <>) of Float; > > Type Identity(Size: Positive) return Matrix is > begin > Return Result : Matrix(1..size, 1..size):= (others => 0.0) do > For index in Matrix'Range(1) loop > Result(Index, Index):= 1.0; > end loop; > End return; > end; > > But I guess that's fairly related to build-in-place; the only difference being > it's not limited. I have not used it for a limited type yet; most of my use cases have been like your example. It is also nice for finalization after picking up the value to be returned, e.g.: function pop return KDF9.word is pragma Assert(the_nest_depth > 0 or the_CPU_state = Director_state); begin return result : constant KDF9.word := the_nest(the_nest_depth - 1) do the_nest(the_nest_depth - 1) := 0; the_nest_depth := the_nest_depth - 1; end return; end pop; -- Bill Findlay with blueyonder.co.uk; use surname & forename;