ceriel@cs.vu.nl (Ceriel Jacobs) (03/08/89)
I have just finished reading the "Report on the Programming Language Modula-2", as it appears in the 4th edition of "Programming in Modula-2", by N. Wirth, published by Springer-Verlag. A new edition of the Modula-2 bible, so to speak. Unfortunately, things have gotten a bit confused. For instance, in paragraph 9.2, page 144, we read: ... The types of corresponding actual and formal parameters must be *compatible* in the case of variable parameters ... (emphasis mine) but in paragraph 10.1, page 149, we read: ... The type of each formal parameter is specified in the parameter list. In the case of variable parameters it must be *identical* with its corresponding actual parameter ... (again, emphasis mine) Also, in chapter 12 of the book, paragraph 12.1, page 52, on variable parameters, we read: ... The types of corresponding formal and actual parameters must be the same ... In paragraph 12 of the Report, page 153/154, we read: ... The type ADDRESS .... is compatible with all pointer types ... ... If a formal parameter is of type ADDRESS, the corresponding actual parameter may be of any pointer type, even if the formal parameter is a VAR parameter ... If the types of the corresponding actual and formal parameter only have to be compatible, the last sentence quoted is a useless remark. Apparently, the texts of the 2nd and the 3rd edition got mixed up a bit (in the 2nd edition, variable parameters only required compatibility). This supposition is supported by the following quote, from paragraph 14, page 156: ... Opaque export is restricted to pointers and to subranges of standard types ... This was in the 2nd edition. The 3rd edition limits opaque export to pointers only. Some more support for this supposition is found in Appendix 1. It contains the syntax of Modula-2, as it appeared in the 2nd edition, not the 3rd! This obviously is a mistake, because this grammar does not correspond to the pieces of grammar quoted in the Report. Also, the syntax diagrams in Appendix 4 are those of the 3rd edition, and thus do not correspond to the syntax in Appendix 1. Another problem is caused by the preface to the 4th edition. On page 5, we read: ... the definition of the language has also undergone a few minor adaptations in the area of Standard Functions: FLOAT(i) and CHR(i) accept an argument of type INTEGER TRUNC(x), HIGH(a), ORD(ch), and SIZE(T) are of type INTEGER ... However, in paragraph 10.2 of the report, page 150, we read: ... ORD(x) ordinal number (of type CARDINAL) ... Of course, the 3rd edition actually was called the "third, corrected edition", whereas the 4th edition is just called the "fourth edition". So, maybe we will soon see a "fifth, corrected edition", followed by a .... :-) Odd numbered editions (except the first) are corrected, even numbered editions are not? -- Ceriel Jacobs, Dept. of Mathematics and Computer Science, Vrije Universiteit, De Boelelaan 1081, 1081 HV Amsterdam, The Netherlands Voice: +31 20 5485577 Email: ceriel@cs.vu.nl
agnew@trwrc.UUCP (Robert A. Agnew) (03/10/89)
In article <2132@ceriel.cs.vu.nl> ceriel@cs.vu.nl (Ceriel Jacobs) writes: > TRUNC(x), HIGH(a), ORD(ch), and SIZE(T) are of type INTEGER >However, in paragraph 10.2 of the report, page 150, we read: > ... ORD(x) ordinal number (of type CARDINAL) ... Remember that in the 4th edition CARDINAL is no longer a type and is now a subtype of INTEGER range [0..32767]. In fact, either an INTEGER or CARDINAL could be used here.
ceriel@cs.vu.nl (Ceriel Jacobs) (03/13/89)
In article <2132@ceriel.cs.vu.nl> I wrote: >> TRUNC(x), HIGH(a), ORD(ch), and SIZE(T) are of type INTEGER >>However, in paragraph 10.2 of the report, page 150, we read: >> ... ORD(x) ordinal number (of type CARDINAL) ... In article <333@trwrc.UUCP> agnew@trwrc.UUCP (Robert A. Agnew) writes: >Remember that in the 4th edition CARDINAL is no longer a type and is now a >subtype of INTEGER range [0..32767]. In fact, either an INTEGER or CARDINAL >could be used here. This is simply not true. In the preface to the 4th edition there only is a remark that many Modula-2 implementations treat a CARDINAL like this. However, in paragraph 7.2 of the book (4th edition), we read: ... Modula does not permit the use of operands of type INTEGER and CARDINAL in the same expression (so-called mixed expressions) ... The whole book treats CARDINAL as a different type from INTEGER, not as a subrange type of INTEGER (just like the 3rd edition). -- Ceriel Jacobs, Dept. of Mathematics and Computer Science, Vrije Universiteit, De Boelelaan 1081, 1081 HV Amsterdam, The Netherlands Voice: +31 20 5485577 Email: ceriel@cs.vu.nl