> But sometimes it is inconvenient for large programs. So I'd like to
> ask how can separate compilation deal with expression templates.
There is a keyword "export" in the ISO C++ standard that allows
programmers to put template declarations in header files and
template definitions in the main source file. Not many compilers
implement this yet (our's does not).
It's unlikely, however, that the "export" keyword will give programmers
anything close to true separate compilation. True separate compilation
allows
each translation unit to be compiled in isolation from the others.
But the C++ model for template compilation more or less requires
compile-time
substitution of actual template parameters in place of formal template
parameters (in order to deal with name lookup and overload resolution).
Thus if x.h declares templates with the "export" keyword, and x.C defines
these expression templates, and another translation unit y.C uses them,
then y.C will have to be recompiled if x.C changes.
So at best, the "export" keyword will give you the illusion of separate
compilation. The compiler will have to secretly force recompilation
as necessary.
I think that C programmers like the split between .h/.c files for three
separate reasons. First, reading the .h file (if commented) is enough
for using the .c file. This reading convenience is not necessary for
separate compilation - Java has true separate compilation, but has done away
with separate files for interface and definition. Second, the .c file can
be
modified and recompiled without recompiling everything else. Third,
proprietary
software can be shipped as .h and.o files.
The three motivations for the split between .h/.c files are
in principal unnecessary. A clever editor could show interfaces
only, a clever incremental compiler could keep track of what needs
to be recompiled, and a compiler could read interfaces from binaries
(as Java compilers do from bytecode files). The hard part is doing all
three in a language expressive enough to allow compile-time metaprogramming.
Arch D. Robison KAI Software, a division of Intel Americas
arch.robison@intel.com 1906 Fox Drive
(217)-356-2288 Champaign IL 61821
Lead developer for KAI C++ http://www.kai.com
--------------------- Object Oriented Numerics List --------------------------
* To subscribe/unsubscribe: use the handy web form at
http://oonumerics.org/oon/
* If this doesn't work, please send a note to owner-oon-list@oonumerics.org
This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 03:20:15 EST