[comp.lang.modula2] global variables in Modula-2

borchert@MATHEMATIK.UNI-ULM.DE (Andreas Borchert) (06/02/90)

rcapener@csulx.weber.edu writes:

> I can see that this makes lots of sense for global types (very similar
> to C's typedef in an #include file), and will indeed work.  But will
> variables be the SAME variables in all the modules that import it, or
> will they be DIFFERENT?  It seems to me that it will be the latter,
> since the storage space will be allocated seperately each and every
> time you compile the object files that import it.  I assume that this
> could be a compiler design issue, but is more likely to be a linker
> problem, but don't know for sure.  Have you tested it with various
> compilers/linkers to see what they all do?  It seems reasonable that
> you may be correct, but then again, is this really defined in the
> language standard?

Import of global variables does not cause any reinstantiation of them.
An import is a reference, not a redeclaration or a copy in the sense
of C's #include.

If you compile a module the compiler allocates space for the global
variables of that module but not for the imported variables.

This is true for all valid Modula-2 compilers.

Andreas Borchert.
borchert@mathematik.uni-ulm.de
borchert@dulruu51.bitnet