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: 103376,ee887b7593f7961b X-Google-Attributes: gid103376,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx01.iad.newshosting.com!newshosting.com!newspeer.monmouth.com!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Ada OS based on Minix3 Date: Fri, 14 Nov 2008 18:11:34 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1pmkcuemqczer.j2i34pvc2lne$.dlg@40tude.net> <81912719-8c66-439d-a40e-529b22acd8a6@u29g2000pro.googlegroups.com> <14t6hwu8udm8j$.1x339y69m2ew1.dlg@40tude.net> <14ay3vz2ngj9s.1bmilwgckl3lc$.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1226704294 29432 192.74.137.71 (14 Nov 2008 23:11:34 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 14 Nov 2008 23:11:34 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:scbTkGBjf+gv0CSbXLguNxo2u5c= Xref: g2news1.google.com comp.lang.ada:2679 Date: 2008-11-14T18:11:34-05:00 List-Id: "Dmitry A. Kazakov" writes: > On Tue, 11 Nov 2008 17:09:54 -0500, Robert A Duff wrote: >> Initialization: Use function calls. They work for all types. >> I think we've discussed this idea before, but I don't remember >> any fundamental problems. > > The fundamental problem is that a constructor cannot be decomposed into > functions. In the function body you have to construct the object before you > return it. Who does it and what? In Ada 2005, a constructor function creates the object via another function call, or via an aggregate, or via an uninitialized variable (to which it assigns components). > Under initialization I do not mean replacing a "default" value with > something else. I mean creation a new object (at some memory location) > initialized by a value. It had no other value before. That's exactly what a function call does: X : T := F(...); F creates a new object. In the limited case, that object _is_ X. In the nonlimited case, it gets copied into X. Either way, X has been turned from "raw bits" into an object of type T -- as you say, "it had no other value before." > Doing this by a function is semantically wrong. I agree with a lot of the rest of what you wrote, which I snipped. But I'm interested in discussing this particular point. It seems to me the whole point of functions is to create new objects. Why is this "semantically wrong"? I understand that there are tricky issues when constructing an object of a specific type and then returning it as a class-wide thing, and possibly storing pointer-to-classwide into global data structures. But I don't get what's fundamentally wrong with using functions as constructors. - Bob