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,21960280f1d61e84 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!nx02.iad01.newshosting.com!newshosting.com!newsfeed2.ip.tiscali.net!tiscali!newsfeed1.ip.tiscali.net!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsinpeer00.lnd.ops.eu.uu.net!bnewsinpeer00.bru.ops.eu.uu.net!emea.uu.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: How come Ada isn't more popular? 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: <1169636785.504223.139630@j27g2000cwj.googlegroups.com> <45b8361a_5@news.bluewin.ch> <3pejpgfbki.fsf@hod.lan.m-e-leypold.de> Date: Fri, 9 Feb 2007 15:02:59 +0100 Message-ID: <1sh134r4r8piq$.wh1w0uitf99t$.dlg@40tude.net> NNTP-Posting-Date: 09 Feb 2007 15:02:59 CET NNTP-Posting-Host: d1b0b008.newsspool2.arcor-online.net X-Trace: DXC=IU]AgEEPg0l<6cDJZfMd_cA9EHlD;3Ycb4Fo<]lROoRaFl8W>\BH3YbX8nJk_6jFmoDNcfSJ;bb[eFCTGGVUmh?dLK[5LiR>kgbE^A`8Lo7HYj X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:9192 Date: 2007-02-09T15:02:59+01:00 List-Id: On Fri, 09 Feb 2007 07:50:43 -0500, Robert A Duff wrote: > Maciej Sobczak writes: > >> The ideal solution is called "constructor", everything else is just >> patchwork. Returning limited types is a compromise that can be >> satisfying in most cases - that's why it's good that Ada 2005 provides >> at least this feature. > > I presume by "constructor", you mean the C++ style feature, right? > > Why is that superior to just using functions as constructors? > Ada has: > > type T(<>) is ... > > to indicate that clients MUST call some constructor function when > creating objects. And it now allows constructor functions (and > aggregates) for limited types. Because it does not compose upon inheritance and aggregation. When inherited the constructing function need to be overridden, even if null record was the only thing added. Further one can barely publicly derive anything from T, which breaks encapsulation. When aggregated: type Outer is record Inner : T .= Constructor_T (...); end there is no way to evaluate the parameters of T's constructing function from ones of Outer. IMO, the constructor concept is cleaner and more general than constructing functions, which are as little functions as ":=" in X : T := 123; is an assignment. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de