Prof. Abimbola A. Olowofoyeku wrote:
Can one use "uses" in a module?
Yes, both are allowed. You can `import' a unit and use a module with `uses'. Both form are allowed both inside modules and units. `uses' used to be more flexible then `import' but now `import' is more powerfull. Namely, `import' allows renames, qualified or selective import:
import GPC qualified;
will do qualified and hence _never_ signal a conflict.
import GPC only (MaxLongInt, ExitCode);
will import only `MaxLongInt' and `ExitCode'. You can use `import' in routines:
functin GetMax : LongInt; import GPC; begin GetMax := MaxLongInt end;
In this case imported identifiers from GPC are visible only inside `GetMax'.
I wrote some time ago:
To clarify rules that I have implemented: for redefinitions it does not matter if you have modules or units. The distinction is made only between `import' and `uses':
import GPC; System;
signals error, while
uses GPC; System;
gives no error. My resoning was that typically exporter can not predict conflicts. On the other hands in importing (`using') module/unit one can decide what is proper way to resolve conflicts. IMHO for new code preffered way is qualified import plus renames. For quick fix in existing code one can change `import' to `uses'.
Later I wrote:
In standard units (`dos.pas' ...) we do:
import GPC (MaxLongInt => Orig_GPC_Maxlongint); System;
the rename prevents the conflict.