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,90108ed846e3f1bf X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!feeder.news-service.com!newsfeed.freenet.de!news.teledata-fn.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Why constructing functions is a mess [was Language lawyer question: task activation (was: Language lawyer question: task activation)) 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: <1dusr7frk73m7.nlsagplge0hk.dlg@40tude.net> <09a7aab3-d105-4a40-b25b-e2824cb12f89@j1g2000yqi.googlegroups.com> <24bdd0df-9554-49de-9c5e-99572c9cdf34@g38g2000yqd.googlegroups.com> <1v0f2pkso7p50.vein84avao5t.dlg@40tude.net> <499ede41$0$32665$9b4e6d93@newsspool2.arcor-online.net> <1lhxmo6l2ypux.bei2ffp1m3e$.dlg@40tude.net> <499f2c59$0$31868$9b4e6d93@newsspool3.arcor-online.net> <1vcaimc8kjj30$.kf3rsd670ebp$.dlg@40tude.net> Date: Sat, 28 Feb 2009 09:13:50 +0100 Message-ID: <1gxn72yzshp07$.6ytqydmmz37u.dlg@40tude.net> NNTP-Posting-Date: 28 Feb 2009 09:13:52 CET NNTP-Posting-Host: a61e2f4e.newsspool2.arcor-online.net X-Trace: DXC=JNW;ZjE[B99L2C_`koXfC5A9EHlD;3Yc24Fo<]lROoR1^YC2XCjHcb9d8LUkWUHga2DNcfSJ;bb[5IRnRBaCdCB6gDk@Fk><76Ie^FL20T5 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:4815 Date: 2009-02-28T09:13:52+01:00 List-Id: On Fri, 27 Feb 2009 17:29:10 -0600, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:1vcaimc8kjj30$.kf3rsd670ebp$.dlg@40tude.net... > ... >>> When a procedure P(Object: out T) returns, there >>> is a yield (in Object). >> >> No, it is not so. The actual of Object out T is constructed *prior* to >> call to P. In contrast the "actual" of F return T is not constructed (when T is >> limited). This is exactly the thing that worries me. Because it makes out >> T and return T different, while they are evidently same. > > To you, maybe, but not in Ada. Even in Ada 83, "out T" and "return T" are > different: > > procedure Foo (P : out String); > function Bar return String; > > Bar creates a *new* object with unknown bounds; Foo takes an *existing* > object with whatever bounds it has. Totally different animals. It is not the difference I am talking about. Your example refers to the types (the constraints of) of the objects, not about whether the objects are constructed or not. The actual of an out parameter is required to be constrained, obviously. > Build-in-place is a rather natural extension to this model. (It's annoying > that we don't have a way to do return-by-reference as well, but that's > another topic). > > Now, I realize you have rather firm ideas about what represents a "proper > type model", but that's pretty much irrelevant to the Ada type model (which > isn't going to change for obvious compatibility reasons). No, "proper" merely means self consistent. The problem with constructing functions is that they are inconsistent. Whatever number of ridiculous constructions (return statement, limited aggregate etc) you would add, the mess will show itself. As a result they would break almost every aspect of Ada as a safe, clean language. We saw what happens with tasks returned by a return statement. They break the contract. Nice. Now a puzzle to you. Topic: large system design, information hiding: type T (<>) is abstract tagged limited private; private type T (...constraints...) is abstract tagged limited record ... end record; In order to be used in type S is new T with ...; function Create (....) return S; Fine? No! How to write Create, the constructing function? See? As a constructor it has to call Create of T. In this case it must do it because where you get the discriminants of T otherwise? But you cannot declare Create on T at all function Create return T; -- You cannot return abstract object! Remember? Constructor is not function. It never will. See the problem? There are constructors that do not produce objects, while any function does. So far. Probably there already is an AI to return abstract objects, which do not exist, or maybe exist, but have some comic accessibility rights etc. It is like the Big Bang, a little inconsistency gives a whole universe of MESS... -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de