comp.lang.ada
 help / color / mirror / Atom feed
From: Jim Rogers <jimmaureenrogers@worldnet.att.net>
Subject: Re: Specialization
Date: Fri, 31 May 2002 01:18:54 GMT
Date: 2002-05-31T01:18:54+00:00	[thread overview]
Message-ID: <3CF6CF7D.8000704@worldnet.att.net> (raw)
In-Reply-To: ad5vj4$euo$1@wanadoo.fr

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





  reply	other threads:[~2002-05-31  1:18 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-30 12:39 Specialization Baugereau
2002-05-30 17:09 ` Specialization Ted Dennison
2002-05-30 17:29   ` Specialization Baugereau
2002-05-30 19:20     ` Specialization Stephen Leake
2002-05-30 19:48       ` Specialization Baugereau
2002-05-31  1:18         ` Jim Rogers [this message]
2002-05-31  5:41           ` Specialization Sergey Koshcheyev
2002-05-31 11:36             ` Specialization Baugereau
2002-05-31 14:08             ` Specialization Jim Rogers
2002-05-31 16:45               ` Specialization Hyman Rosen
2002-05-31 17:05               ` Specialization Sergey Koshcheyev
2002-05-31 17:40                 ` Specialization Hyman Rosen
2002-05-31 20:04                   ` Specialization Sergey Koshcheyev
2002-05-31 21:25                     ` Specialization Hyman Rosen
2002-05-31 13:27         ` Specialization Stephen Leake
2002-05-31 19:46           ` Specialization Simon Wright
2002-06-01 15:30             ` Specialization Stephen Leake
2002-05-31 19:44   ` Specialization Simon Wright
2002-06-01 15:25     ` Specialization Stephen Leake
2002-06-01 17:12       ` Specialization Simon Wright
2002-06-01 19:50         ` Specialization Stephen Leake
2002-05-30 17:46 ` Specialization Toshitaka Kumano
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox