🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.modula2
Article #1712

RE: Initialisation code: When is it called?

#1712
From: RW_GRIFFITHS
Date: Tue, 29 Jan 1991 11:39
26 lines
1835 bytes
The importation of a module causes the imported module to be initialized as
the program (that imports the module) begins to execute. Since many different
modules may be imported by many others (in a large program etc), it is necessary
 to give an ordering for the initialization. This order is the one in which
they are textually listed in the import statement. The compilere works out the
orderuing


 by examing the main program module first and then works backwards. IF
there is a circularity in the initialization order ( ie two modules importing
from each other) then strictly speaking the order is undefined; but most
 compilers can resolve this problem. For example TopSpeed M2 initializes in an
 order
staring with the last module in the circular reference list, before repetitio
n occurs. Eg. in the case of A importing B, B importing C and C importing A,
the initialization order would be C, then B then A. However remember that
this will not be portable to other compilers.
Finally there is another rare case
hen compilers can produce different
initialization orders for the same program. This occurs when a module is
 imported into a definition module and then not used in the corresponding
 implementationmodule. In such cases some compilers do not initialize the
 imported module.

Rob Griffiths
The Open University
Technical Details
Message-ID: <INFO-M2%91012907064459@UCF1VM.BITNET>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!tut.cis.ohio-state.edu!ucbvax!VAX.ACS.OPEN.AC.UK!RW_GRIFFITHS

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!tut.cis.ohio-state.edu!ucbvax!VAX.ACS.OPEN.AC.UK!RW_GRIFFITHS
From: RW_GRIFFITHS@VAX.ACS.OPEN.AC.UK
Newsgroups: comp.lang.modula2
Subject: RE: Initialisation code: When is it called?
Message-ID: <INFO-M2%91012907064459@UCF1VM.BITNET>
Date: 29 Jan 91 11:39:04 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Reply-To: Modula2 List <INFO-M2%UCF1VM.BITNET@ucf1vm.cc.ucf.edu>
Organization: The Internet
Lines: 26