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: a07f3367d7,5a88548f1bcf3510 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Received: by 10.180.104.170 with SMTP id gf10mr367776wib.3.1353554746188; Wed, 21 Nov 2012 19:25:46 -0800 (PST) Path: q13ni13026wii.0!nntp.google.com!feeder1.cambriumusenet.nl!feed.tweaknews.nl!216.196.110.142.MISMATCH!border3.nntp.ams.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!rt.uk.eu.org!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Overring function and its returned type Date: Mon, 19 Nov 2012 16:19:49 +0100 Organization: cbb software GmbH Message-ID: <104675gvcsndz.1v2aaipa7277i$.dlg@40tude.net> References: <97a6946f-a707-4dd3-872b-9e851fcf9462@googlegroups.com> <62ba75d8-8a6c-4d75-be37-3322f683714d@googlegroups.com> <8998c0eb-c9b1-4501-9163-94172aa4aea0@googlegroups.com> <5533c59b-24a1-41ae-8a7c-674e3cdcbecc@googlegroups.com> <687a06e4-3545-444d-9fbe-4e2e5f7055f2@googlegroups.com> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: FbOMkhMtVLVmu7IwBnt1tw.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 8bit Date: 2012-11-19T16:19:49+01:00 List-Id: On Mon, 19 Nov 2012 05:04:25 -0800 (PST), AdaMagica wrote: > On Monday, November 19, 2012 9:41:07 AM UTC+1, Hibou57 (Yannick Duch�ne) wrote: >>> How can this be? The actual of an out-parameter exists already, whereas >>> the return object is newly created. >> >> He meant it, semantically. You can return a value into an already existing >> object, and in practice, except with purely functional languages, that's >> always how it goes (even if the target may be adjusted in some way for >> many reasons). > > From this point of view, they are semantically the same in Ada. But for me, it's a non sequitur. > > An out parameter as an update is like an assignment A := B; hidden inside > some procedure; a return object is constructed somehow. Even if the target already exists? Out parameters cannot be used together with assignment but I would not consider it a semantic difference. It is a syntactic artefact IMO. > This is fundamentally different for me. > > Is (1) equal to (2): > declare > A: T := Some_Value; -- (1) > begin > A := Some_Value; -- (2) But function result is definitely not initialization, if you meant that. So 1 and 2 are exactly same, except for semantically broken limited returns, of course. Furthermore, starting with Ada 2005 which borrowed FORTRAN's idea of named result you could have the result constructed inside a function: return Result : T do -- It is constructed here end return; You could even have it constructed and destructed more than once! (unfortunately) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de