[Oberon] Modula2 vs Oberon IMPORT
bob at web-options.com
Sat Jan 8 11:23:52 CET 2011
> Happy New Year Everybody!
> I see that in Modula only the required procedures are IMPORTed, like:
> FROM STextIO IMPORT WriteString, WriteLn;
> Conversely, in Oberon, the whole Module has to be IMPORTed in order to
> get to use the equivalent procedures.
> It would seem to me that Oberon "programs" would be that much more
> "bloated" with unnecessary code. Am I correct in this conclusion? Is
> there a way to selectively IMPORT procedures in Oberon? It doesn't
> appear to me to be possible.
In Modula-2 it is implementation-dependent - I don't think the language
report says anything about it. A clever compiler would only import
components that were explicitly referenced in the source code
(cascade-loading dependencies as required); an even cleverer compiler would
optimise away any unreachable code.
Qualified import doesn't imply that only the specified components are
loaded, although it could be used as a compiler hint I suppose. It really
just gives you the opportunity to obscure your code by not qualifying the
component idents at the point of use.
With Oberon the components are loaded and unloaded on demand or by the
garbage collector. In this case qualified import would just be a way of
avoiding writing the full module name. Oberon gives you a different way of
obscuring your code by using the rename feature, eg IMPORT Prolixity := P;
[...] P.Obfuscate; [...].
Component Pascal goes even further and lets you ignore part of the module
name. eg IMPORT StdLog; [....]; Log.Write( ...
More information about the Oberon