J
Jerry Coffin
[ ... ]
Comeau implements 'export' for templates. From the viewpoint of the
front-end, 'export', by itself, consists primarily of putting the
keyword into the right place in the scanner. To use the keyword
properly, the front-end also needs to implement two-phase lookup, which
quite a few (most?) others don't.
That's a pretty serious amount of hard work, but it's more or less the
easy part as far as supporting export goes -- once you have a front-end
that recognizes it correctly, you have to figure out some way to make it
work. In Comeau's case, a pre-linker is used -- Greg may jump in to
correct me on this, but I believe this is part of the mechanism used to
get exported templates to work.
The basic problem is more or less one of circularity: when you write an
exported template, the compiler doesn't have _nearly_ all the
information necessary to generate code for the template. That only
becomes available when the template is instantiated over some particular
type. There are a number of problems, but one of the primary ones is
basically one of circularity: you have to be ready to re-do most of the
code-generation parts of compiling the template every time it's
instantiated over a new type.
Following the typical flow of starting with source files, compiling to
object files, then linking them together (adding code from libraries as
needed) simply doesn't fit well with this. You can't compile a template
to normal object code that's ready for linking until you know the type
over which its being instantiated.
In Comeau's case, he does part of the job with a pre-linker that runs
after the compiler back-end, but before the linker. The details are
probably proprietary, but I suspect this is used (among other things) to
take a "compiled" template and generate code for it instantiated over a
particular type.
The bottom line is that although there are other compilers that use the
EDG front-end, TTBOMK, none of them implements export.
By Comeau you mean latest EDG frontend based? Or is Comeau some way
different from the others?
Comeau implements 'export' for templates. From the viewpoint of the
front-end, 'export', by itself, consists primarily of putting the
keyword into the right place in the scanner. To use the keyword
properly, the front-end also needs to implement two-phase lookup, which
quite a few (most?) others don't.
That's a pretty serious amount of hard work, but it's more or less the
easy part as far as supporting export goes -- once you have a front-end
that recognizes it correctly, you have to figure out some way to make it
work. In Comeau's case, a pre-linker is used -- Greg may jump in to
correct me on this, but I believe this is part of the mechanism used to
get exported templates to work.
The basic problem is more or less one of circularity: when you write an
exported template, the compiler doesn't have _nearly_ all the
information necessary to generate code for the template. That only
becomes available when the template is instantiated over some particular
type. There are a number of problems, but one of the primary ones is
basically one of circularity: you have to be ready to re-do most of the
code-generation parts of compiling the template every time it's
instantiated over a new type.
Following the typical flow of starting with source files, compiling to
object files, then linking them together (adding code from libraries as
needed) simply doesn't fit well with this. You can't compile a template
to normal object code that's ready for linking until you know the type
over which its being instantiated.
In Comeau's case, he does part of the job with a pre-linker that runs
after the compiler back-end, but before the linker. The details are
probably proprietary, but I suspect this is used (among other things) to
take a "compiled" template and generate code for it instantiated over a
particular type.
The bottom line is that although there are other compilers that use the
EDG front-end, TTBOMK, none of them implements export.