VOSSLOH@DB0TUI11.BITNET (Klaus Vossloh) (11/16/87)
MODULE LAYOUT; (*---------------------------------------------*) (* We made good experiences with the following *) (* layout in combination with *) (* grouping related objects and algorithm. *) (* The layout is not very compact but seems to*) (* be readable. *) (*---------------------------------------------*) FROM PCIO IMPORT Con, WriteString; CONST Co1 = 12; Co2 = 17; TYPE Ty1 = (El1, El2); Ty2 = (El3, El4); VAR Va1 : Ty1; Va2 : Ty2; PROCEDURE Pr1(Pa1 : Ty1; Pa2 : Ty2); CONST Co3 = 24; Co4 = 37; TYPE Ty3 = (El5, El6); Ty4 = (El7, El8); VAR Va3 : Ty3; Va4 : Ty4; PROCEDURE Pr2(Pa3 : Ty3; Pa4 : Ty4); CONST Co5 = 98; Co6 = 45; TYPE Ty5 = (El9, El10); Ty6 = (El11, El12); VAR Va5 : Ty5; Va6 : Ty6; Va7 : ARRAY [1..4711] OF REAL; PROCEDURE Pr3(Pa5 : Ty5; Pa6 : Ty6); VAR I, J : CARDINAL; BEGIN (* Pr3 *) FOR I:=1 TO 12 BY 2 DO REPEAT WHILE FALSE DO IF TRUE THEN J := I + 1 ELSIF NOT TRUE THEN J := I - 1; RETURN ELSE WriteString(Con, "Aha.$"); Va7[13] := 1.0 END (* If *) END (* While *); Pr1(Va1, Va2) UNTIL TRUE END (* For *) END Pr3; BEGIN (* Pr2 *) END Pr2; BEGIN (* Pr1 *) END Pr1; BEGIN (* LAYOUT *) END LAYOUT.
hal@pur-phy (Hal Chambers) (11/17/87)
In article <INFO-M2%87111613494632@DB0TUI11> Info-Modula2 Distribution List <INFO-M2%UCF1VM.bitnet@jade.berkeley.edu> writes: > IF TRUE THEN > J := I + 1 > ELSIF NOT TRUE THEN > J := I - 1; ..... I would also recommend using semicolon as a statement terminator rather than a separator. Modula-2 specifically allows the extra semicolon so that this may be done. IF TRUE THEN J := I + 1; ELSIF NOT TRUE THEN J := I - 1; ..... Although it isn't syntactically required, it results in a more uniform appearance to the code. Also, if a substantial block of code follows the IF and you latter add more statments to the block, it is easy to miss the omitted semicolon when the J:=I+1 is no longer the last statment of the block. Admittedly this is a matter of style (read: personal preference) and I do not claim that the form omitting the semicolon is in any sense "ugly" or anything like that. Hal Chambers