Quite some time ago, Waldek Hebisch wrote:
Gale Paeper wrote:
<snipped general explanations>
I think you missed an important point: interfaces _have to_ brak normal textual scope rules. 6.2.2.2 states that inteface is a separate region outside of the program text -- in particular inteface is a different region then an export list.
Note that 6.11.2 tells us that exportable-name give as defining point in the interface. General rules (especially 6.2.2.7) tell us that the occurence of exportable-name is simultaneously an applied occurence of identifier in export list, which is defined later.
Frank Heckenbach wrote:
A question to the EP experts. Are these things allowed?
a) module m; export m = (a => a); const a = 1; end; end.
Illegal. The first "a" is a constant-identifier applied occurrence whose defining point location is in a region outside the "m" interface region. The second "a" is a constituent-identifier defining occurrence which by point 4 above makes the first "a" an illegal construct.
The same analysis would indicate that
module n; export n = (a); const a = 1; end; end.
is illegal. However my reading is that modules `m' and `n' are equivalent. Namely, in both cases we have applied occurence of `a' in the export-list, reffering to the definition of constant `a' and a defining point of `a' in the interface -- since interface and export-list are different regions both can coexist.
c) module m; export m = (a => b, a); const a = 1; end; end.
Illegal. The first "a" is a constant-identifier applied occurrence whose defining point location is in a region outside the "m" interface region. The second "a" is a constituent-identifier defining occurrance which by point 4 above makes the first "a" an illegal construct.
Again legal, defining occurences are in the in the interface, applied occurrences are in the export list.
Just to be sure before I'll change GPC: Gale, do you agree to Waldek's analyis (i.e., all of my examples should work)?
What about the following case? It's also ok, isn't it? (Exporting b = 1.)
module m; export m = (a => b); const a = 1; b = 2; end; end.
P.S. Frank, quite some time ago in the comp.lang.pascal.ansi-iso newsgroup you asked a question about exporting with possibly renaming predefined/required identifiers and I don't think you every got an ISO 10206 based answer.
There was an answer from John Reagan: "I don't think we intended to allow that. I'd have to look closer at your investigation to find the right words." (news:comp.lang.pascal.ansi-iso, subject "Exporting of predefined identifiers", Feb 2003).
The 6.2.2.9 b) define-before-use rule exception I mentioned in export interface regions point 3 which requires exportable-names to have module-heading region defining-points in conjunction with 6.2.2.10 which conceptually places all but four of the required identifiers in a region enclosing the program is what precludes exporting with possibly renaming all but two of the required identifiers.
I think that 6.2.2.9 b) do not forbid anything -- it allows normal case (exporting identifiers declared in module-heading), but just normal rules allows exporting predefined identifiers -- they are already defined when export list is seen, so there is no need to apply 6.2.2.9 b).
So you (Waldek) mean all predefined identifiers can be exported (and reimported with renaming)? This would allow strange things such as:
Foo (Bar : 42);
(if `Foo' was imported/renamed from `WriteLn'). I hope not. ;-)
The two exceptions are input and output. For those two, defining points are created in the module-heading region either with the useage as a module parameter or with importing the required interfaces StandardInput and StandardOutput into the module-heading. (StandardInput and StandardOutput are the other two of the four required identifiers not covered by 6.2.2.10 but interface identifiers aren't exportable-names and thus cannot be renamed.)
Currently GPC doesn't allow exporting `Input' and `Output', but I think it's not too difficult to change this. Do we agree that this is correct (with and without renaming)?
Frank