Does EP allow a module to export a predefined identifier? The standard makes it clear that it can re-export an identifier imported from another module (e.g., 6.11.6, example 2), but what about predefined things?
As in my other mail, I can't seem to find a wording that prohibits it (but I might overlook something).
In particular, exporting "magic" routines with renaming would seem quite confusing to me.
module m interface;
export m = (WriteLn => Foo);
end.
program p;
import m;
begin Foo (1 : 2) { Nice!? } end.
If this is allowed, the problem in the `System' unit with the redeclaration of `Integer' could be resolved by letting the `GPC' module export `Integer' with renaming, so `System' could use the renamed one on the right side of the redeclaration (`type Integer = OriginalInteger (16);'). But somehow I doubt this is alright ...
Frank
On Wed, Jan 29, 2003 at 02:12:20AM +0100, Frank Heckenbach wrote:
Does EP allow a module to export a predefined identifier? The standard makes it clear that it can re-export an identifier imported from another module (e.g., 6.11.6, example 2), but what about predefined things?
As in my other mail, I can't seem to find a wording that prohibits it (but I might overlook something).
This may be relevant:
6.11.2 Export-part
[...]
The occurrence of an exportable-name in an export-clause shall constitute the defining-point of the identifier of the constant-identifier, type-identifier, schema-identifier, variable-identifier, procedure-identifier, or function-identifier contained by the exportable-name as a constituent-identifier for the region that is the interface denoted by the identifier of the export-part that contains the export-clause. The occurrence of an identifier in an export-renaming-clause of an export-clause shall constitute the defining-point of that identifier as a constituent-identifier for the region that is the interface denoted by the identifier of the export-part that contains the export-clause.
[...]
6.2.2.10
Required identifiers that denote the required values, types, schemata, procedures, and functions shall be used as if their defining-points have a region enclosing the program (see 6.1.3, 6.4.2.2, 6.4.3.4, 6.4.3.6, 6.4.3.3.3, 6.7.5, 6.7.6, and 6.10).
IMHO this means that predefined identifiers cannot be exported, because they would have two different "defining-points" for different regions.
Emil
Emil Jerabek wrote:
On Wed, Jan 29, 2003 at 02:12:20AM +0100, Frank Heckenbach wrote:
Does EP allow a module to export a predefined identifier? The standard makes it clear that it can re-export an identifier imported from another module (e.g., 6.11.6, example 2), but what about predefined things?
As in my other mail, I can't seem to find a wording that prohibits it (but I might overlook something).
This may be relevant:
6.11.2 Export-part
[...]
The occurrence of an exportable-name in an export-clause shall constitute the defining-point of the identifier of the constant-identifier, type-identifier, schema-identifier, variable-identifier, procedure-identifier, or function-identifier contained by the exportable-name as a constituent-identifier for the region that is the interface denoted by the identifier of the export-part that contains the export-clause. The occurrence of an identifier in an export-renaming-clause of an export-clause shall constitute the defining-point of that identifier as a constituent-identifier for the region that is the interface denoted by the identifier of the export-part that contains the export-clause.
[...]
6.2.2.10
Required identifiers that denote the required values, types, schemata, procedures, and functions shall be used as if their defining-points have a region enclosing the program (see 6.1.3, 6.4.2.2, 6.4.3.4, 6.4.3.6, 6.4.3.3.3, 6.7.5, 6.7.6, and 6.10).
IMHO this means that predefined identifiers cannot be exported, because they would have two different "defining-points" for different regions.
But isn't this also true when re-exporting an imported identifier?
: 6.11.3 : : [...] : : For each constituentÂidentifier having a definingÂpoint for the region that : is the interface denoted by the interfaceÂidentifier of an : importÂspecification : : a) the occurrence of that interfaceÂidentifier shall constitute the : definingÂpoint of that constituent identifier for each region that is a : constituentÂidentifier contained by the importÂspecification.
Frank
On Wed, Jan 29, 2003 at 10:11:03PM +0100, Frank Heckenbach wrote:
Emil Jerabek wrote:
On Wed, Jan 29, 2003 at 02:12:20AM +0100, Frank Heckenbach wrote:
Does EP allow a module to export a predefined identifier? The standard makes it clear that it can re-export an identifier imported from another module (e.g., 6.11.6, example 2), but what about predefined things?
As in my other mail, I can't seem to find a wording that prohibits it (but I might overlook something).
This may be relevant:
6.11.2 Export-part
[...]
The occurrence of an exportable-name in an export-clause shall constitute the defining-point of the identifier of the constant-identifier, type-identifier, schema-identifier, variable-identifier, procedure-identifier, or function-identifier contained by the exportable-name as a constituent-identifier for the region that is the interface denoted by the identifier of the export-part that contains the export-clause. The occurrence of an identifier in an export-renaming-clause of an export-clause shall constitute the defining-point of that identifier as a constituent-identifier for the region that is the interface denoted by the identifier of the export-part
^^^^^^^^^ The language is quite obfuscated. Here, "interface" is not the text of a module interface, as I thought, but rather the virtual entity that is exported by the module, ...
that contains the export-clause.
[...]
6.2.2.10
Required identifiers that denote the required values, types, schemata, procedures, and functions shall be used as if their defining-points have a region enclosing the program (see 6.1.3, 6.4.2.2, 6.4.3.4, 6.4.3.6, 6.4.3.3.3, 6.7.5, 6.7.6, and 6.10).
IMHO this means that predefined identifiers cannot be exported, because they would have two different "defining-points" for different regions.
But isn't this also true when re-exporting an imported identifier?
: 6.11.3 : : [...] : : For each constituentÂidentifier having a definingÂpoint for the region that : is the interface denoted by the interfaceÂidentifier of an : importÂspecification : : a) the occurrence of that interfaceÂidentifier shall constitute the : definingÂpoint of that constituent identifier for each region that is a : constituentÂidentifier contained by the importÂspecification.
^^^^^^^^^^^^^^^^^^^^^^ ... and here, the region of this defining-point is only _inside_ the import clause. (Imported identifiers are defined for the enclosing block via the last paragraph of 6.11.3, and points b), c) and d), which you probably had in mind.)
Anyway, I didn't find other objections to exporting predefined identifiers in the standard. (Although renaming "writeln" looks quite strange, as you pointed out.)
Emil
Frank
-- Frank Heckenbach, frank@g-n-u.de, http://fjf.gnu.de/, 7977168E GPC To-Do list, latest features, fixed bugs: http://www.gnu-pascal.de/todo.html GPC download signing key: 51FF C1F0 1A77 C6C2 4482 4DDC 117A 9773 7F88 1707
Emil Jerabek wrote:
... and here, the region of this defining-point is only _inside_ the import clause. (Imported identifiers are defined for the enclosing block via the last paragraph of 6.11.3, and points b), c) and d), which you probably had in mind.)
Anyway, I didn't find other objections to exporting predefined identifiers in the standard. (Although renaming "writeln" looks quite strange, as you pointed out.)
Thanks. It seems reasonable to me. To make sure I'll ask in the newsgroup (about both issues), before I make any according changes in GPC ...
Frank