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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,927ae253da8bb547 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-30 18:18:54 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!news-out.nuthinbutnews.com!propagator-sterling!news-in.nuthinbutnews.com!cyclone1.gnilink.net!wn3feed!worldnet.att.net!bgtnsc05-news.ops.worldnet.att.net.POSTED!not-for-mail Message-ID: <3CF6CF7D.8000704@worldnet.att.net> From: Jim Rogers User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:0.9.4) Gecko/20011128 Netscape6/6.2.1 X-Accept-Language: en-us MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Specialization References: <4519e058.0205300909.5bfb317d@posting.google.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Fri, 31 May 2002 01:18:54 GMT NNTP-Posting-Host: 12.86.33.194 X-Complaints-To: abuse@worldnet.att.net X-Trace: bgtnsc05-news.ops.worldnet.att.net 1022807934 12.86.33.194 (Fri, 31 May 2002 01:18:54 GMT) NNTP-Posting-Date: Fri, 31 May 2002 01:18:54 GMT Organization: AT&T Worldnet Xref: archiver1.google.com comp.lang.ada:25048 Date: 2002-05-31T01:18:54+00:00 List-Id: Baugereau wrote: > > Ok so this is the difference of philosophy with STL's vector, which is plain > value-oriented. > What I dislike here is the lack of locality of the elements, and the need to > "new" every time I add an element... > Any comment? The difference is that in C++ you "new" the element before you add it to the vector (in the constructor). You then pass a reference (or pointer) to the vector. The C++ vector does not require heavy weight copy semantics for add an element because it only really adds a reference. The same is being done in Ada. The difference is that objects in C++ are so commonly passed by reference that you forget what is going on. Ada is simply making the situation clear by requiring you to dynamically allocate a copy of the object. If you were to dynamically allocate all your objects in Ada, just as you do in C++, then the container would not need to perform any of the dynamic allocation. You could simply add references to the objects just like you do in C++. You will also find that Ada scoping rules are much more strict than C++ scoping rules. This can influence the way you design your container package. Jim Rogers