Path: utzoo!mnetor!uunet!husc6!bloom-beacon!tut.cis.ohio-state.edu!mailrus!ames!pasteur!ucbvax!ksuvax1.BITNET!harv From: harv@ksuvax1.BITNET (Harvard Townsend) Newsgroups: comp.lang.modula2 Subject: "FOR loop" control var. and limit expression types Message-ID: Date: 7 Apr 88 17:15:54 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: Info-Modula2 Distribution List Organization: The Internet Lines: 43 I am interested in people's opinions on the restrictions of compatibility between a FOR loop control variable and the types of limit expressions. On page 158, section 9.8, of Wirth's 3rd, corrected ed. of Programming in Modula-2, he states that the limit expressions (he calls them the starting value and limit) must be "compatible" (as distinct from "assignment compatible") with the control variable. On page 65, he says "Two types are are said to be compatible, if they are declared as equal or satisfy certain compatibility rules to be discussed subsequently. An important case of exceptional compatibility are the types INTEGER and CARDINAL. Hence, the assignment i := c is admissible." Finally, on page 148, section 6.3, he says "A type T1 is said to be compatible with a type T0, if it is declared either as T1 = T0 or as a subrange of T0, or if T0 is a subrange of T1, or if T0 and T1 are both subranges of the same (base) type." At least one text book on Modula-2 says that the limit expressions must be "assignment compatible" with the control variable (see p. 103 of "Modula-2 Discipline & Design" by Arthur Sale, Addison-Wesley, 1986). The issue arose during my work to port the 1-pass MC68K native code ETH compiler. The parser appears to define yet another type of compatibility. It allows the starting value to be truely "assignment compatible". However, the limit must be either 1) equal type with the control variable or, 2) a CARDINAL constant < MAX(INTEGER) when the control variable is an INTEGER type. In other words, it does NOT allow a CARDINAL variable limit with an INTEGER control variable, a CARDINAL constant limit with a CARDINAL control variable, a CARDINAL variable limit with a CARDINAL control variable, etc. I intend to change it to allow a free mix of CARDINAL and INTEGER control variable and limit expressions, but I wanted to get others opinions and interpretations first. Have the standardization committees dealt with this? ______________________________________ Harvard Townsend, Systems Manager Dept. of Computing & Information Sciences Kansas State University, Manhattan, KS 66506 (913)532-6350 CSNET: harv@cis.ksu.edu -or- harv@kansas-state.csnet BITNET: harv@ksuvax1.bitnet -or- harv%ksuvax1.bitnet@cunyvm.cuny.edu UUCP: ihnp4!wnuxa!ksuvax1!harv -or- ...!psuvax1!ksuvax1.bitnet!harv AT&T Mail: attmail!htownsend