J. David Bryan wrote:
EP is clear on that an interface module requires an implementation.
Yes, but must that implementation be an EP module? EP 6.13 section 2d suggests not, saying that interfacing to other languages might be provided by:
"The association of a module-heading with a construct in another language that the implementation has determined to be equivalent to a module-block."
That would seem to indicate that an interface-only EP module is legal if an appropriate implementation is provided elsewhere.
It is just an informal ("NOTES") suggestion ("could be provided in one of the following ways") for "an extension", which to my understanding means that such a mechanism would be just as non-standard as any other.
...gives me:
ifmod.pas:7: unresolved forward declaration `proc'
GPC is looking for an implementation of "proc" in the module-block, which makes sense. So that means that I need to declare "proc" external as well.
If it's external, you must declare it `external'. That should always have been so, but GPC didn't strictly check it until the major changes in the area of `asmname', `external' etc. in 20030323.
I have re-read the thread "Modules without implementation" at:
http://www.gnu-pascal.de/crystal/gpc/en/thread8400.html
Gale Paeper suggests adopting the "implementation advice" in EP 6.1.5, i.e.:
"A processor may provide, as an extension, the interface-directive external, which is used to specify that the module-block corresponding to the module-heading containing the interface-directive is in some form other than an Extended Pascal module-block (e.g., it is implemented in some other language)."
Whereas you suggest the EP 6.1.4 mechanism:
"...I prefer to specify this on a per routine basis, because it's not generally optimal to have everything or nothing external...."
I take your point, except in the case where everything _is_ provided by an external module (e.g., interfacing to a non-Pascal library). In that case, it is tedious and error-prone to append "external" after each of perhaps dozens or hundreds of routines.
It can easily be automatized. Besides, if you want to declare external routines, you have to specify the linker name (aka asmname), anyway, and writing `attribute (name = 'foo')' vs. `external name 'foo'' isn't so much easier or harder.
When you (previously) wrote an interface-module without a corresponding implementation-module, you were kind of "cheating", since the interface claims that a Pascal implementation of the routines declared (without `external') would follow, whereas it didn't and was replaced (at link time) by a C (or whatever) implementation. Due to the bug that module initializers weren't called, this happened to work. In addition, you were apparently relying in C code on the default linker name of Pascal routines (first letter upper-case, rest lower-case) which is also a bad idea and will break at least when qualified identifiers are added.
Frank