Proposal to add modules to C

Henry Spencer henry at utzoo.UUCP
Sat May 18 02:59:10 AEST 1985

> It seems to me that the main (if not only) reason to avoid using global
> variables (as opposed to ``module-level'' variables, i.e., accessible
> to foo.c and bar.c but not baz.c) is to avoid name collisions.  If the
> variable makes sense as a statically-allocated unit, why would you care
> whether baz.c can get at it, unless you want to ensure that no accidental
> changes or references are made?

Because I want to ensure that no *deliberate* changes or references are
made!!  That variable is a detail of the *implementation* of the module
in question, and outsiders are not entitled to use it because the
implementation is subject to change.  There are some really ugly places
in Unix where programs *know* details of the implementation of stdio,
for example.  Making things like that globally accessible essentially makes
them part of the specification of the module, hence very hard to change
even if they are later seen as serious mistakes.
				Henry Spencer @ U of Toronto Zoology

More information about the Comp.lang.c mailing list