Linkers, etc, and Object Code Templatey-Type-Things?

Simon G Best <s.g.best@btopenworld.com>
1 Feb 2004 12:45:14 -0500

          From comp.compilers

Related articles
Linkers, etc, and Object Code Templatey-Type-Things? s.g.best@btopenworld.com (Simon G Best) (2004-02-01)
Re: Linkers, etc, and Object Code Templatey-Type-Things? ppluzhnikov@charter.net (Paul Pluzhnikov) (2004-02-04)
Re: Linkers, etc, and Object Code Templatey-Type-Things? s.g.best@btopenworld.com (Simon G Best) (2004-02-08)
Re: Linkers, etc, and Object Code Templatey-Type-Things? cdodd@acm.org (Chris Dodd) (2004-02-08)
| List of all articles for this month |
From: Simon G Best <s.g.best@btopenworld.com>
Newsgroups: comp.compilers
Date: 1 Feb 2004 12:45:14 -0500
Organization: Very little.
Keywords: linker, question, comment
Posted-Date: 01 Feb 2004 12:45:14 EST

Hello!


I'm wondering if there is an object file format / linker which
includes/implements object-code 'macros'/'templates' - general sort of
metaprogramming-type-stuff at the object code level. And after a bit of
searching around, I've ended up here :-)


The other day, while lamenting GCC's lack of support for C++'s
'export'ing of templates, a thought occurred to me. This thought
started off as this observation: the sort of genericity which C++
supports through its template mechanisms is the sort of genericity which
doesn't just sit on top of the rest of the language, but seems to go
right down to the object code level. This quickly lead to the actual
thought itself: the 'natural' way to implement 'export' would be to have
object code templates in the object code itself!


That way, there'd be no need for the linker to have to mess around
with invoking the compiler to compile those extra template
instantiations that can arise during linking, and that sort of
malarkey. (The idea of linkers needing to invoke compilers to 'finish
off' the compilation always seemed terribly untidy to me. I am aware
that there are (or at least may be) other solutions (such as using
databases to keep track of which translation units export which
templates), but there's always this looming feeling of kludginess
about such things.)


So, rather than just have symbols in object files, I want to have
something more along the lines of (meta)functions (rather like the
function-like macros in the C preprocessor). Such functions would
take symbols and/or values as arguments, and return instantiations.
The definitions/bodies of such functions would then be the templates
I'm looking for :-D


Or something like that.


(Obviously, such a linker and object file format would also involve the
use of an assembler that also supports such
macros/templates/metafunctions and assembles them into a suitable form
for the linker. Or, at least, the compilers would need to encode such
things in the assembly code somehow to 'send it through' to the linker.)


Do such linkers / object file formats exist? (And are they open-source?
    Particularly for Unixy-type systems?)


:-)


Simon


PS: I've not just got C++ in mind. I'm also interested in using such
an object linking system for other languages.
[I don't recall seeing anything like that. It seems to me that unless the
kinds of stuff you can put into the macros is extremely simple, you'll
end up with a full code generator anyway. -John]


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.