🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #2095

Re: definition module loops

#2095
From: Lars J|dal
Date: Mon, 13 May 1991 10:08
58 lines
2494 bytes
bowen@cs.Buffalo.EDU (Devon E Bowen) writes:


>In article <1991May12.071720.29928@ibmpcug.co.uk>, gmurray@ibmpcug.co.uk (G Murray) writes:
>|>  Stony Brook explicitly states that circular imports are not allowed.

>Sounds good to me (a lot easier to implement). But at the end of section
>14 of the Report on The Programming Language Modula-2 in Wirth's book, he
>says

>	If circular references occur among modules, their order of
>	initialization is not defined.
...

As far as I know, this corresponds to the implementation modules, not
the definition modules. That is, suppose you have the following modules:

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.

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.
(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 |
+--------------------------------------------------------------------------+
Technical Details
Message-ID: <1991May13.100833.13386@daimi.aau.dk>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!bloom-beacon!eru!hagbard!sunic!dkuug!daimi!protonen
References: <1991May12.071720.29928@ibmpcug.co.uk> <76170@eerie.acsu.Buffalo.EDU>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!cis.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!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.100833.13386@daimi.aau.dk>
Date: 13 May 91 10:08:33 GMT
References: <1991May12.071720.29928@ibmpcug.co.uk> <76170@eerie.acsu.Buffalo.EDU>
Sender: protonen@daimi.aau.dk (Lars J|dal)
Organization: DAIMI: Computer Science Department, Aarhus University, Denmark
Lines: 58