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,f8a440310f7f2e02 X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news3.google.com!feeder.news-service.com!feeder4.cambrium.nl!feed.tweaknews.nl!193.141.40.68.MISMATCH!npeer.de.kpn-eurorings.net!npeer-ng2.kpn.DE!newsfeed.arcor.de!newsspool2.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Extended return question 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: <69940bd4-74f7-4b00-93d6-482c7394fcef@34g2000hsf.googlegroups.com> Date: Thu, 10 Jul 2008 20:36:51 +0200 Message-ID: <1pdpniur1w9sq$.1a9h7prydviae$.dlg@40tude.net> NNTP-Posting-Date: 10 Jul 2008 20:36:53 CEST NNTP-Posting-Host: 7713624e.newsspool3.arcor-online.net X-Trace: DXC=9W_0OPZ0V6MAa;:RKVJ>LEMcF=Q^Z^V3H4Fo<]lROoRA8kF?kNZ@K[6LHn;2LCVN[i8EfOnYNdn?W On Thu, 10 Jul 2008 08:19:41 -0700 (PDT), Adam Beneschan wrote: > The upshot of this AI is, I think, that (1) the object > being worked on for an extended return is *not* an "alias" for the > object being created, even for a limited type, and (2) although > limited types aren't supposed to be copied, this is true only in an > Ada semantic sense, and implementations are allowed to do any block- > copies they wish as long as they get the Ada semantics right. Right, and the position 1 is inconsistent with the notion of limited type. A "backdoor" 2 does not save it as the following example illustrates: with Ada.Finalization; with Ada.Text_IO; use Ada.Text_IO; procedure Test_Return is package Test is type T is new Ada.Finalization.Limited_Controlled with null record; overriding procedure Finalize (X : in out T); overriding procedure Initialize (X : in out T); function Create return T; end Test; package body Test is procedure Finalize (X : in out T) is begin Put_Line ("Finalized"); end Finalize; procedure Initialize (X : in out T) is begin Put_Line ("Initialized"); end Initialize; function Create return T is begin return X : T do raise Constraint_Error; end return; exception when Constraint_Error => return X : T; end Create; end Test; use Test; X : T := Create; begin null; end Test_Return; The output should be: Initialized Finalized Initialized Finalized This is a case when *a* limited object is initialized and finalized twice, which is semantically inconsistent. OK, Initialize is not a constructor. But we could rewrite the above so that Create would call itself multiple times over the "same" X before it would finally "return" X! -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de