Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!usc!sdd.hp.com!elroy.jpl.nasa.gov!ncar!gatech!bloom-beacon!eru!hagbard!sunic!dkuug!daimi!protonen From: protonen@daimi.aau.dk (Lars J|dal) Newsgroups: comp.lang.modula2 Subject: Re: definition module loops Message-ID: <1991May13.110458.13833@daimi.aau.dk> Date: 13 May 91 11:04:58 GMT References: <1991May12.071720.29928@ibmpcug.co.uk> <76170@eerie.acsu.Buffalo.EDU> <1991May13.100833.13386@daimi.aau.dk> Sender: protonen@daimi.aau.dk (Lars J|dal) Organization: DAIMI: Computer Science Department, Aarhus University, Denmark Lines: 53 I forgot to define a main program to use the modules. The modules should be DEFINITION MODULE m1; VAR x:CARDINAL; END m1. DEFINITION MODULE m2; VAR y:CARDINAL; END m2. IMPLEMENTATION MODULE m1; FROM m2 IMPORT y; VAR x:CARDINAL; BEGIN x:=1; y:=1; END m1. IMPLEMENTATION MODULE m2 FROM m1 IMPORT x; VAR y:CARDINAL; BEGIN x:=2; y:=2; END m2. MODULE main_program; FROM m1 IMPORT x; FROM m2 IMPORT y; FROM InOut IMPORT WriteCard; BEGIN WriteCard(x,0); WriteCard(y,0); END main_program. >If they are compiled in the above order the definition modules will not >use anything undefined. The implementation modules know the type of the >foreign variable (x or y), so there is no problem either. But it is >undefined whether the body of m1 or m2 is executed first, so if one >compiler ends up with x=1 and y=1, you have no guarantee another compiler >will do the same. So the output should be 11 or 22, but the one is as correct as the other. >(Only Wirth know if that was what he meant so please correct me if I'm >wrong :-) ) >Good luck with the implementation! +--------------------------------------------------------------------------+ | Lars J|dal | (put your favourite quotation here) | | protonen@daimi.aau.dk | | |--------------------------------------------------------------------------| | Computer Science Department - Aarhus University - Aarhus - Denmark | +--------------------------------------------------------------------------+