Frank Heckenbach wrote:
Some time ago, I wrote:
Gale Paeper wrote:
Imports in an interface module are not visible in the corresponding implementation module. But they are visible in the implementation when using a "simple" module like this:
module sysutils; export sysutils = all; import GPC; System;
end;
var a: TString;
end.
At least that's GPC's current behaviour. Perhaps the EP experts can confirm whether this is correct?
Unless I'm missing something, I think paragraph 6.2.2.12, "Each defining-point that has as a region a module-heading shall also have as a region the module-block that is associated with that module-heading.", requires imports into a "separated" module-heading to be treated just the same as your "simple" module case.
If, as indicated, GPC doesn't make heading imports "visible" in the corresponding implementation block, then GPC isn't in full conformance with ISO 10206 requirements.
I'll fix it in the next release (chief47*.pas).
While trying to do so, I found the following program in the test suite. That's wrong then, i.e., the second `import' has to be removed, right?
module nick1m2 interface; export nick1m2 = all; import nick1m1;
[...]
end.
module nick1m2 implementation; import nick1m1;
[...]
end.
You're correct in that the test program is wrong in having a module-heading imported interface-identifier repeated in the corresponding module-block import-specification. As presently written, the compiler should generate some kind of multiple definition error when it sees the second "nick1m1" import in the module nick1m2 implementation; code block.
Per paragraph 6.11.3, there is a imported-interface-identifier defining point for "nick1m1" in the module-heading region. Since paragraph 6.2.2.12 also puts that defining point in the module-block region, the "only one defining point per identifier spelling per region" requirement of paragraph 6.2.2.7 prohits having a import-specification in the module-block with a interface-identifier with the same speclling as "nick1m1". (Note: Paragraph 6.2.2.7 has an exemption for imported identifiers meeting certain requirements; however, imported-interface-identifiers don't fall within the exemption criteria.)
In fixing the test program, I think it would be a good idea to end up with two test programs. One which is fixed to be a legal Pascal program which performs the intended test of the original program. And a second one which specifically tests that the compiler will detect and fail this sort of module-heading and module-block inport interface-identifier duplication error.
Gale Paeper gpaeper@empirenet.com