CBFalconer wrote:
Frank Heckenbach wrote:
... snip ...
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.
The whole asmname/external name thing is non-standard, so it should be as plainly understandable as possible. Thus I would favor 'externalname' as the ONLY available method. The standard allows for directives following the procedure declaration, and I am not sure if the separate words in 'external foo' qualify. 'external' by itself is a common usage.
ISO 7185 says:
: 6.1.4 Directives : : A directive shall only occur in a procedure-declaration or a : function-declaration. The only directive shall be the required : directive forward (see 6.6.1 and 6.6.2). No directive shall have : the same spelling as any word-symbol. : : directive = letter { letter | digit } . : : NOTE -- Many processors provide, as an extension, the directive : external, which is used to specify that the procedure-block or : function-block corresponding to that procedure-heading or : function-heading is external to the program-block. Usually it is : in a library in a form to be input to, or that has been produced : by, the processor.
So any directive except `forward' is an extension. GPC's principle is to (aim to) support ISO Pascal without extensions in CP and EP modes, and to support various extensions otherwise. So, any kind of external directive should not be accepted in CP/EP mode, and that's how it is currently.
Now, in BP, we have `external name 'foo''. Sure, this is not even syntactically in accordance with 6.1.4 -- but neither would be `externalname 'foo'' since 6.1.4 doesn't allow for "arguments" (the string) of directives. Since there's no way (even syntactically) in ISO to make a directive with a name (neither `attribute', of course), we have to do something outside of ISO -- and if nothing else matters, we might as well use the BP syntax ...
Besides, please note that `external' and `[asm]name' are really two distinct things (which, unfortunately, GPC doesn't strictly separate yet). There are cases where you only need to specify the name (so it can be referred to from other languages), and other times you want to make it external without specifying the name (well, provided the name is something that can be relied upon, such as the Pascal identifier converted to lower-case).
Therefore, we do need several directives -- in my suggestion `external', `external name ...', and `attribute (name = ...)'.
I agree with you that we should not have too many redundant directives. That's why I suggest to drop the (currently existing) `asmname', `c' and `c_language' directives (and keep only the, also already existing, `external' and `attribute').
Frank