[Oberon] Modula2 vs Oberon IMPORT
chris at gcjd.de-web.ws
Sat Jan 8 17:45:12 CET 2011
Duke Normandin wrote:
>IMHO, "clever" compilers that IMPORT _only_ the required code, is the
I think there is a misunderstanding of import of symbols and code and
separate compilation in general here.
If a module is compiled the compiler writes a symbol file which contains
information (names etc.) about the module and all exported symbols and a
object file which contains the code for this module. There is no code in
a symbol file.
If a second module is compiled which imports the first
module, the compiler reads the symbol file of the first module. The
object file, which contains the code of the second module has only
references to code and variables in the first module which must be
resolved by a linker. That could be a static linker or a loadtime
linker like the one in the original Oberon system.
How this is done depends on the system used.
>Yes! I realized that about qualified IMPORTs - after all, the entire
>Module is referenced in the IMPORT statement. Qualified imports simply
>allow you to use procedures with the same name, as I understand it.
Qualified import is more or less a syntax feature and most likely not
related to the implementation of the code generator.
>My concern is this - if a "main" Module IMPORTS 10 "slave" Modules,
>but uses only (e.g.) one procedure from each, then the code bloat in
>the final executable would be absurd, would it not? I might as well
>cut-n-paste the code into the "main" module, and re-use the code that
>way. Maybe this something a "peephole optimizer" could do?
As explained above no such thing will happen. The compiler moves symbols
around. No code, only references to external code are handled by the
Hope this helps,
More information about the Oberon