Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!usc!merlin.usc.edu!girtab.usc.edu!jeenglis From: jeenglis@girtab.usc.edu (Joe English) Newsgroups: comp.lang.c++ Subject: Re: Abstract vs. Template classes Message-ID: <5881@merlin.usc.edu> Date: 20 Oct 89 18:27:36 GMT References: <21000004@inmet> <6590308@hplsla.HP.COM> Sender: news@merlin.usc.edu Reply-To: jeenglis@girtab.usc.edu (Joe English) Organization: University of Southern California, Los Angeles, CA Lines: 50 jima@hplsla.HP.COM (Jim Adcock) writes: >Hm, I always thought the "whole" idea of the C++ approach, and templates in >particular, was to avoid the additional gratuitous indirections present in >other OOPLs, thus retaining C-like speed. In which case "template" needs to >be a macro-like implementation, with little capabilities for machine-code reuse. Why not allow both templates (macroexpanded) and abstract member functions (compiled once and using virtual pointers to parameter type operations)? In the parameterized class, you could define small functions as inline, medium sized functions that make lots of references to the class parameters as templates, and let large functions that make few parameter references be compiled once and stuck in a library. The compiler would create a virtual function table for parameter operations for every different instantiation of the parameterized class. Of course, an implementation could *probably* do that anyway using the template syntax, if all of the needed parameter operations were declared: class OrderedList { T::operator<(); // T must have the comparison operators; T::operator<(); // The addresses of these functions would be placed T::operator==(); // in the paramater table of OrderedList instantiations OrderedList& insert(T&); // makes calls thru parameter table template OrderedList& delete(T&) // macroexpanded // ... etc. }; >I would think one could "fake" genericity via "gratuitous-indirection" >relatively trivially by coercing the type of pointer used in derived classes. Yes, but one of the reasons for wanting parameterized classes in the first place is to make this kind of code rewriting unnecessary. By the way, how long before parameterization is fully supported? What will it look like? --Joe English jeenglis@nunki.usc.edu