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=0.6 required=5.0 tests=BAYES_20,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1025b4,43ae7f61992b3213 X-Google-Attributes: gid1025b4,public X-Google-Thread: 103376,faf964ea4531e6af X-Google-Attributes: gid103376,public From: Ed Avis Subject: Re: GPL and "free" software Date: 1999/05/02 Message-ID: <372CBCA7.52206CB5@doc.ic.ac.uk>#1/1 X-Deja-AN: 473281356 Content-Transfer-Encoding: 7bit References: <3729D0F6.3DF2CCED@doc.ic.ac.uk> <925572182snz@vision25.demon.co.uk> <372C1824.1417502F@doc.ic.ac.uk> <925653268snz@vision25.demon.co.uk> Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@doc.ic.ac.uk X-Trace: lux.doc.ic.ac.uk 925678759 28136 146.169.49.30 (2 May 1999 20:59:19 GMT) Organization: Mime-Version: 1.0 NNTP-Posting-Date: 2 May 1999 20:59:19 GMT Newsgroups: comp.lang.ada,gnu.misc.discuss Date: 1999-05-02T20:59:19+00:00 List-Id: Phil Hunt wrote: >>If the program instantiates a List of Int, then the code for >>List is called and passed pointers (or references) to Ints. If the >>program wants a List of Char, then the same object code can be used, >>being passed pointers to Chars. >I think you've got it horribly wrong (there might be C++ compilers >that work like that, but I imagine they are very rare, produce slow code >and are horrible to implement). > >What C++ does is constructs code for the template with T changed to >int, compiles it, and produces code for the template with T changed >to char, and compiles that as well. I see. That seems a much less efficient way to do things, but what do I know about compiler design? I'm sure that not every language supporting generic types does it this way. For a start, some are interpreted. You've convinced me that a program compiled, and dynamically linked, against a library containing template classes really does contain bits of that library embedded in the program code. I think you could probably work around this, by creating a thin wrapper: class List_wrapper method add(Object o) (or void *) call List.add(o) end method (etc.) and then substitute List_wrapper for List everywhere in your program. The object code for List_wrapper would contain bits of code from List, but the rest of your program would not, and you could link the two together at runtime. You lose the benefit of template type-checking this way, but AFAIK, it's only used at compile time, not runtime (at least in C++), so you could develop without the wrapper, then stick it in for your final release. -- Ed Avis Advertise here! epa98@doc.ic.ac.uk