My feeling is that as long as you don't lose
procedure Foo; external;
whatever you choose doesn't matter (for me!). I think it'd be an idea to leave open the option that the user wants to directly refer to the external name (as in the example above) and resolve any renaming issue via wrappers or the export mechanism should they choose to. It may have a run-time overhead, but it might make for easier initial interfacing to large external libraries.
FWIW, I prefer the options to be:
procedure foo; external; procedure foo; external 'name=_foo' ; procedure foo; external 'name=_foo; language=c' ; procedure foo; external 'language=c' ;
Where language could be any number of things: asm, c, c++, etc.
You can alter the stuff in the quotes to your heart's content without breaking the overall syntax of:
procedure <name> ; [ external [ '<attribute-list>' ] ; ] <attribute-list> ::= '<attribute-item> { ; <attribute-item> }' <attribute-item> ::= name | language = <string>
Obviously, you could invent other syntaxes (is that a word?) for the attribute list.
One thing I like is that since the attribute keywords are within quotes, its obvious they don't conflict with any identifiers that the user might choose to use (ie. they have a very explicit context in which they exist).
I suppose you could argue that the external keyword gives the context so the quotes are not needed, but I still feel happier with them inside quotes as in principle you could have it such that all keywords not in quotes are globally recognised as defined-keywords (and hence conflict with user's identifiers) and only those in quotes are treated as "local" (and hence not conflicting with user's identifiers). It'd make for one simple rule for identifier that's easy to follow.
Just my 2c...
Grant
At 2:47 PM +0100 25/2/03, 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';
will be equivalent to
procedure Foo; external; asmname 'bar';
`external name' is BP compatible, AFAIK.
I'm not yet changing the fact that `asmname' implies `external' for routines -- this should be done, too, but I'd rather do it together with other incompatible changes later.
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 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.
Of course, it would be possible to make `external' set the first-uppercase-asmname even then, but I'm not sure how useful this is. (Currently, it's chosen as the default to avoid linker conflicts with "usual" C routines, but with name mangling, this won't be an issue.)
So, to me it seems more reasonable to make a plain `external' set the asmname to all-lowercase (just like `c' and `c_language' do now). Then,
procedure Foo; c;
can be turned to simply:
procedure Foo; external;
But a current
procedure Foo; external;
will have to be turned to:
procedure Foo; external name 'Foo';
(or the corresponding C code turned to `foo' in lowercase, which I'd usually recommend -- since these routines are explicitly coded, you usually know that there are no conflicts with libc etc.).
Another question is whether `asmname' should be dropped entirely. In external declarations (the most common case), it can be turned into `external name' as described above. But there are cases where you need to set the asmname of a non-external routine or variable. But perhaps we can just use `name' then, e.g.:
var Foo: Integer; name 'bar';
(instead of asmname 'bar'). The advantage would be to have another non-standard (conditional) keyword less. Or we could even use `attribute', something like:
var Foo: Integer; attribute (name ('foo'));
(or `asmname' -- that doesn't matter since within `attributes' we don't have the problems of keywords, anyway). This way, `name' would not be a real keyword (only special after `external'), at the cost of a little stranges syntax.
But while we're at it, I think the attribute syntax can be simplified to
var Foo: Integer; attribute (name = 'foo');
(also for other attributes with parameters, and without changing the existing syntax -- there wouldn't be any conflicts).
I think this could be an acceptable way (syntactically), so `asmname' can be dropped.
Frank
-- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: 51FF C1F0 1A77 C6C2 4482 4DDC 117A 9773 7F88 1707