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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,e859f774bbb3dfb3 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!club-internet.fr!feedme-small.clubint.net!feeder1-1.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: another way to shoot yourself in the foot? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <54157920-377a-441b-9b0b-f0c4f9ddffec@f36g2000hsa.googlegroups.com> <54435596-5e7f-4686-a2b7-1e22d7c4b186@p25g2000hsf.googlegroups.com> Date: Sat, 21 Jun 2008 10:56:10 +0200 Message-ID: <483ugmvkl2ea.1hrqsq7ru4t1x$.dlg@40tude.net> NNTP-Posting-Date: 21 Jun 2008 10:56:10 CEST NNTP-Posting-Host: 273907d0.newsspool4.arcor-online.net X-Trace: DXC=;Ml51^kBg4V@>[RYkFXOIP4IUK\BH3YR\_I^hlCSGCZDNcfSJ;bb[UIRnRBaCd On Fri, 20 Jun 2008 23:37:11 GMT, Jeffrey R. Carter wrote: > Robert A Duff wrote: >> >> Build-in-place is determined by the type, not by the >> syntactic form of the return statement. > > I'm not sure I see any point to the extended return statement. I agree, it was introduced solely for dealing with limited-valued functions. IMO there should be no such thing as "limited-valued" at all. In-place initialization should be handled by proper constructors. > Wouldn't it have > been clearer and simpler to have done something like > > Result : return T; Result : T renames return; -- Would be IMO better, semantically it is a renaming. > ... > begin > ... > return Result; Why this? With your syntax it is clear what is going to be returned: function Foo return T is Result : return T; -- This will be the result begin ... end Foo; -- Returns Result, obviously, as declared > with a rule that only 1 "return variable" may be in scope at a time? As well as that there may be no return statements returning something else... One problem with your proposal is: function Foo (...) return String is begin declare Result : return String (1..200); -- Going to return 200 characters begin Result (1) := 'a'; -- Here the result has to be allocated if HALT (x) then return; -- Return from Foo with Result end if; end; -- Drop already allocated and initialized result return "Hallo!"; -- Return a completely different thing end Foo; -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de