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,21960280f1d61e84 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news4.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!kanaga.switch.ch!irazu.switch.ch!news-zh.switch.ch!switch.ch!cernne03.cern.ch!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: How come Ada isn't more popular? Date: Fri, 09 Feb 2007 15:12:38 +0100 Organization: CERN News Message-ID: References: <1169636785.504223.139630@j27g2000cwj.googlegroups.com> <45b8361a_5@news.bluewin.ch> <3pejpgfbki.fsf@hod.lan.m-e-leypold.de> NNTP-Posting-Host: abpc10883.cern.ch Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: cernne03.cern.ch 1171030358 31011 137.138.37.241 (9 Feb 2007 14:12:38 GMT) X-Complaints-To: news@@cern.ch NNTP-Posting-Date: Fri, 9 Feb 2007 14:12:38 +0000 (UTC) User-Agent: Thunderbird 1.5.0.9 (X11/20061220) In-Reply-To: Xref: g2news2.google.com comp.lang.ada:9195 Date: 2007-02-09T15:12:38+01:00 List-Id: Robert A Duff wrote: > I presume by "constructor", you mean the C++ style feature, right? The feature in general. C++ is just one example from many languages that got it right. > Why is that superior to just using functions as constructors? The constructor, as a language feature, more clearly describes its own purpose. It's also entirely independent on other properties of the type. > Ada has: > > type T(<>) is ... > > to indicate that clients MUST call some constructor function when > creating objects. This indicates that the type has unknown discriminants. The concept of "discriminant" is completely irrelevant to the intent here, even though in this particular case the combination of this concept and other language features leads to the fact that there must be some constructor function called. I treat it as an idiom that allows me to finally achieve the goal, but not as a direct support for the feature that would be most accurate. > I'm talking about Ada 2005, of course. I agree that limited types were > rather painful in Ada 95. Yes. And this answers your question why constructors are superior - they are superior, because as a direct feature related to value initialization it would be completely independent on other properties of the type, like whether it is limited or not. Ada 2005 has patched this, but with direct suppor for constructors there would be nothing to patch - constructor initializes the value "in place", not as a result of returning value from somewhere and special-casing it for limited types. There is also a question of how to initialize a generic type. Again, the question is really about a direct language feature. -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/