Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!cs.utexas.edu!sun-barr!olivea!apple!netcom!aed From: aed@netcom.COM (Andrew Davidson) Newsgroups: comp.lang.c++ Subject: Re: Generics in C++ Keywords: generic Message-ID: <1991Apr9.221621.15934@netcom.COM> Date: 9 Apr 91 22:16:21 GMT References: <1410@h.cs.wvu.wvnet.edu> Organization: Netcom - Online Communication Services UNIX System {408 241-9760 guest} Lines: 53 In article <1410@h.cs.wvu.wvnet.edu> schiebel@cs.wvu.wvnet.edu (Darrell Schiebel) writes: > >We are designing a reuseable software library based on C++ components. >Currently we are exploring the various (twisted) ways of implementing >a "generics" layer on C++. The alternatives seem to be: > > 1) Pointer Based Objects on top of C++ (Smalltalkish) can you give more detas? Is this just polymorphism > 2) Pre-processor based macro generics with type substitution and > using the "generic header file." I would advice you avoid using macros, if for no other reason than they are hard to debug. Try using templeting instead > 3) A yacc/sed/awk preprocessor for implimenting the generics > ((C++)++) sound like this would be even worse than using generic.h. (At least using generic.h is in the domain of c++) > >These soulutions are poor, but C++ doesn't seem to have the flexibility >to allow for a seemless integration of these sorts of constructs into the >language. The type structure doesn't seem to be rich enough. have you looked at using polymorphism with inheritance and container classes? have you thought about using dynamic linking and loading. Under this sinario you would focus on building a flexable frame work which allows the user to add new classes or replace clases (or parts of them) to suit there particluar needs. There are several ways to do this. If you are on sun workstations, you might want to look at the way they use shared lib. If this is not enough, then you should look at supporting true dyanmic linking and loading. (SYS V R4, SUNOS 4.1, there are several other lib packages that also do this kind of think in SYS V r3 and BSD Andy -- ----------------------------------------------------------------- "bede-bede-bede Thats all Folks" Porky Pig Andy Davidson Woodside CA. aed@netcom.COM -----------------------------------------------------------------