Frank Heckenbach wrote:
Waldek Hebisch wrote:
It seems much better to avoid users doing mangling by hand. And even if support for other languages is delayed it is better to reserve the syntax in advance.
Well, which syntax? The existing and suggested syntax only covers explicitly specified asmnames (which should always be possible, of course).
So if we want to support other language's mangling schemes in the future (which is probably more than one can of worms, and I'm not sure if will be feasible, given that even different C++ compilers use different schemes), we need some additional syntax.
A new `attribute' can always be added (no danger of conflicts).
If you're thinking of something like `external 'C' ...' (similar to `extern "C"' in C++), there might be conflicts since BP actually allows (which GPC doesn't support yet, but might in the future):
external 'library-name' name 'asmname';
So, which syntax do you propose?
I would be happy with an attribute, say procedure Foo(x: real); attribute (external, name = 'foo(double)', linkage = 'C++');
BTW, I do not think one should emulate other language's mangling manually, either. But it also works if all languages allow you to specify an explicit linker name for the interface routines -- in C that's trivial (no mangling at all), in GPC that's `asmname' (subject to the proposed changes), in C++ it's `extern "C"' (not for objects, though, but the incompatibilities between C++ and GPC objects are much deeper than the name mangling, anyway). I don't know enough Fortran or Ada to tell if there are such mechanisms ...
Ada has linkage pragmas. Both Ada and C++ have overloaded functions, one cannot export them using C linkage. Of course one can solve such problems using wrappers, but that doubles the volume of code needed for interfacing (and adds runtime overhead).