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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no 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 10:44:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!isdnet!enst!enst.fr!not-for-mail From: Toshitaka Kumano Newsgroups: comp.lang.ada Subject: Re: Specialization Date: Fri, 31 May 2002 02:46:11 +0900 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: References: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset=iso-2022-jp Content-Transfer-Encoding: 7bit X-Trace: avanie.enst.fr 1022780642 12054 137.194.161.2 (30 May 2002 17:44:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Thu, 30 May 2002 17:44:02 +0000 (UTC) Return-Path: X-Mailer: Mozilla 4.78 [ja] (Win98; U) X-Accept-Language: en-US,en,ja Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.8 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: comp.lang.ada mail<->news gateway List-Unsubscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:25020 Date: 2002-05-31T02:46:11+09:00 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