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!news3.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: Tue, 13 Feb 2007 10:02:22 +0100 Organization: CERN News Message-ID: References: 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 1171357342 10167 137.138.37.241 (13 Feb 2007 09:02:22 GMT) X-Complaints-To: news@@cern.ch NNTP-Posting-Date: Tue, 13 Feb 2007 09:02:22 +0000 (UTC) User-Agent: Thunderbird 1.5.0.9 (X11/20061220) In-Reply-To: Xref: g2news2.google.com comp.lang.ada:9302 Date: 2007-02-13T10:02:22+01:00 List-Id: Randy Brukardt wrote: >> Is a direct support for constructors a whiz-bang but inflexible package? >> In what way? > > Because there is no single concept of a constructor. You need at a minimum a > copy-constructor and a default-constructor, and then you still have > flexibility issues. Ada chose to decompose these things into their > constituent parts. I understand that. > You haven't clearly explained what the difference between a function and a > constructor is. When we (the ARG) looked at this problem, we eventually > decided (at least from an Ada semantics perspective) that there was in fact > no difference. The difference (as I perceive it) is in the coupling that the "function" has with its corresponding type. If it is a function just as any other, then the fact that it is a constructor function is only a matter of convention. Sometimes it is just a naming convention (for example, when the function is called "Initialize" or "Create", etc. then it might be a hint that it is a constructor function), but the fact is the the term "constructor function" is used by Ada programmers and that means that they treat it in a somewhat special way. By coupling the constructor with the type, the intent is expressed more clearly and then the purpose is not a result of naming convention. As an example, consider (C++): template void fun(const U &u) { T t(u); // or: T *p = new T(u); // ... } This is truly generic with only two parameters - there is no need to drag around the name of the constructor function to instantiate the template. > Thus we decided that it didn't make sense to have a special > feature for the purpose. Which I understand. Still, achieving the effect of forced initialization requires from me to jump somewhere else for concepts that are not directly related to the problem at hand. -- Maciej Sobczak : http://www.msobczak.com/ Programming : http://www.msobczak.com/prog/