Eike Lange wrote:
On Tue, Feb 25, 2003 at 02:47:46PM +0100, Frank Heckenbach wrote:
As another small step towards cleaning up the `external' mess in GPC, I'm now implementing `external name', i.e. procedure Foo; external name 'bar';
Looks good, as far as
var Name: Integer; external name 'name';
works. ("Name" is a very popular identifier).
Yes, this will work. (To make sure it will remain so, I'm putting it in a test program eike4.pas.)
However, unless there's heavy resistance, I'd like to deprecate the `c' and `c_language' directives, and drop them in a later release. So, procedure Foo; c; should be turned to: procedure Foo; external name 'foo';
What about: procedure Foo; external cname 'foo'; in case of resistance ;-)
I think if there's resistance, it will be against any change. I don't think there's a particular problem with `external name' (and it's BP compatible, unlike `external cname' or any other new creation would be).
What about a plain `external' without `name' or `asmname'? Currently, this keeps the "default" asmname (first letter uppercase, the rest lowercase). Some time in the future, we'll need name mangling (for qualified identifiers and overloading), so the default asmname will be something ugly which one should not have to know about in order to write interfacing C code or such.
I do not want to rewrite all my units interfacing C code. In C, all function names are lowercase with "_" between (gtk_window_new). In Pascal, this function would be called "GtkWindowNew".
That's independent of the meaning of plain `external' since it will not work here, anyway (neither the existing, nor any possible future meaning), because of the underscores. (If, however, the Pascal function would be called Gtk_Window_New, which I don't suggest(!), a plain `external' would work after the proposed change.)
So something simlar to "asmname", "external name", or "attribute (name = 'XXX')" would be good.
Of course, we need at least one of these. In such a case, I'd then recommend `external name', though `external; attribute (name = ...)' would also work (but is longer) according to my suggestions.
We "need" `external name' for BP compatibility (and there doesn't seem to be a problem with it -- the preceding `external' avoids any syntax conflicts, even if `name' is no real keyword), so we might as well use it ...
And we need something for non-external routines. `attribute' might be good there, and if we do it, it will also work for external routines ...
var Foo: Integer; attribute (name ('foo'));
This syntax looks unnatural to me, is it Lisp code?
No, GCC extension. (OK, so where's the difference? ;-)
Frank