Jonas Maebe wrote:
On 01 Nov 2006, at 20:46, Frank Heckenbach wrote:
It would be more like an embedded foreign-language section (such as 'extern "C"' in C++, which is of course simplified by the fact that the syntax of C and a subset of C++ is very similar), but IMHO "external;" is not like this.
You're misunderstanding what I'm trying to say. The following:
procedure t; external;
and
procedure T; external;
are also equivalent (as I literally said in my original post). Just like it is in GPC. And I also said that they only become different if you add cdecl (or C in MacPas) mode, i.e.
procedure t; cdecl; external;
keeps the name 't' and
procedure T; cdecl; external;
keeps the name 'T'.
Yes, OK, so it's with "cdecl", but it doesn't change the point.
But, and here's where the misunderstanding comes in, you can't have both with the same parameter list in one compilation unit because when calling them from Pascal code, the Pascal casing rules are applied (i.e., whether you write t or T later on, both resolve to one and the same identifier).
No misunderstanding, I didn't actually assume they could both be used in the same scope (more precise than compilation unit -- at least in GPC, you could have them in different scopes in the same compilation unit). Actually it didn't even occur to me that they could possibly (and I'm glad they can't in FPC).
But Pascal's case-insensitivity rule is stricter than just disallowing, e.g., "procedure foo;" and "procedure Foo;" in the same scope. It says that the two declarations are equivalent for all purposes.
Florian Klaempfl wrote:
Frank Heckenbach schrieb:
Florian Klaempfl wrote:
Frank Heckenbach schrieb:
syntactic rules change to that of another language,
It's not about syntax but abi.
Identifier case-insensitivity is part of the Pascal syntax.
Any ABI that assigns different meanings to the same identifier with different case is not consistent with this syntax.
I've the strange feeling that you didn't get how it works in FPC.
I think I do. As Jonas explained:
procedure t; cdecl; external;
gets the [linker-level] name 't' and
procedure T; cdecl; external;
gets the [linker-level] name 'T'. If there's more to it, feel free to explain.
However, I don't doubt that FPC works this way. I just pointed out that this doesn't conform to Pascal syntax rules (and that this doesn't matter for FPC), because whatever the compiler does internally, or which ABI it follows, according to Pascal rules, the identifier "t" is the same as "T", thus the two declarations are exactly the same, and thus any well-defined (in the mathematical sense) behaviour must be the same for both.
Frank