comp.lang.ada
 help / color / mirror / Atom feed
From: Toshitaka Kumano <kumano@cl.cilas.net>
Subject: Re: Specialization
Date: Fri, 31 May 2002 02:46:11 +0900
Date: 2002-05-31T02:46:11+09:00	[thread overview]
Message-ID: <mailman.1022780642.29604.comp.lang.ada@ada.eu.org> (raw)
In-Reply-To: ad56du$pp4$1@wanadoo.fr

Hi,

Baugereau wrote:
> I'm trying to implement a generic container, say a extensible vector.
> But I'd like to specialize this component for controlled types.
> For instance, when I empty the container, I want to Finalize all the
> elements if they are Controlled, and do nothing if not.

Roughly speaking, Finalize for Controlled is equivalent to
"destructor" in C++, and usually it is called automatically
and implicitly when the object cease to live.

In usual usage when Finalize is called, you lose the container itself,
not only the elements :-)

So your statement "when I empty the container" is very strange to me
 because you seem to invoke explicitly...

> Is there a way, like in C++ (I come from a C++ background, maybe my view is
> too much "C++ template"-biased), to specialize the procedures of the package
> for some flavours of the generic parameter?

Guess from "template", you need not dynamic dispatching (virtual in C++).

Then my guess answer is:

  - use derived type simply (say C and Derived_C) 
    (not tagged, probably limited private)

  - implement different versions of "Empty" for two types
    (one for C does nothing (?), another for  Derived_C removes elements) 

Although I don't have much experience in C++ and could not give much help,
why don't you show your idea in some piece of code in C++ ?
Then you could get hints from some gurus who have experience both on C++
and on Ada.

--
Toshitaka Kumano
Kamakura
Japan



      parent reply	other threads:[~2002-05-30 17:46 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         ` Specialization Jim Rogers
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 ` Toshitaka Kumano [this message]
replies disabled

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