Path: utzoo!attcan!uunet!mcvax!hp4nl!maestro!fransvo From: fransvo@maestro.htsa.aha.nl (Frans van Otten) Newsgroups: comp.lang.modula2 Subject: Re: Re^2: Error in PD Modula-2 compiler? Or just in my brain? Message-ID: <944@maestro.htsa.aha.nl> Date: 29 May 89 14:46:55 GMT References: <340@actisb.UUCP> <1090@gmdzi.UUCP> <1231@infbs.UUCP> Reply-To: fransvo@htsa.UUCP (Frans van Otten) Organization: AHA-TMF (Technical Institute), Amsterdam The Netherlands Lines: 77 Martin Neitzel writes: >4. It is a known ambiguity in the Modula2 report: Can standard > identifiers be redefined or not? In procedures, definitely yes, but > the situation in modules is not clear at all. The situation is perfectly clear. But first, read this: I realize the 'report'-part of the book should contain all on Modula-2. But let me quote Wirth from some other chapters in Programming in Modula-2, third, corrected edition: In chapter 11, "The concept of locality", Wirth writes: " The standard identifiers of Modula are considered to be declared in an imaginary procedure enclosing the program. " " These rules may also be remembered by the algorithm is which the declaration of a given identifier i is searched: First, search the declarations of the procedure P in whose body i occurs; if the declaration of i is not among them, continue the search in the procedure surrounding P; then repeat this same rule until i is found. " So it is legal to redeclare a standard identifier within a procdure. Nothing is stated yet about redeclaring them in a module. From this quatation you could also conclude that standard identifiers are unknown in local modules (unless specifically imported), but the module-concept is introduced after that, in chapter 23. In chapter 24, "Definition and implementation parts", we find: " Standard identifiers are automatically imported into all modules. " Which settles that problem. Now in chapter 26, "Local modules", we read: " ... (unless one also considers a main program to be not only a module, but also a procedure). " A bit ambiguous, but you can read in this that Wirth doesn't think this viewpoint is wrong. And if a main program also is a procedure, you can redeclare identifiers. Remember, Wirth wrote (I quote again): " The standard identifiers of Modula are considered to be declared in an imaginary procedure ENCLOSING the program. " (Emphasis mine.) Although this doesn't say anything about local modules, it would be unlogical to allow redeclaration in the main module but not in local modules. The above is from the "normal" chapters in the book, not from the report. The report should contain all information on Modula-2, and serve as a reference and arbiter. So forget the above, and read on: In the report we find in chapter 4, "Declarations and scope rules", first alinea: " Every identifier occuring in a program must be introduced by a declaration, unless it is a standard identifier. The latter are considered to be predeclared, and they are all valid in all parts of a program. For this reason they are called pervasive. " This says it all. Valid in ALL parts of the program, pervasive... They always prevail, even when redeclared. So the situation is perfectly clear (from the report). Of course, compared to the other quotations, this is not consistent. So I decided for the compiler I'm developing: " The standard identifiers can be considered to be declared in every (local and global) module, prior to any import. Between the standard identifiers and the rest of the module (including the import part) is an imaginary procedure border. Importing may be considered the same as declaring. " -- Frans van Otten | fransvo@maestro.htsa.aha.nl or Algemene Hogeschool Amsterdam | fransvo@htsa.uucp or Technische en Maritieme Faculteit | [[...!]backbone!]htsa!fransvo