Initializing extern variables

Guido van Rossum guido at mcvax.UUCP
Tue Jun 5 13:34:11 AEST 1984


Doug Gwyn:
>	I think it is better to init the extern data explicitly
>	(even if it is zero) in a module that deals with the data.
	^^^^^^^^^^^^^^^^^^^^

While I agree with the rest of what you say (less initialized data,
inited in a separate module), I don't agree with the idea of initializing
zero data explicitly.  Reasons:

1) Initialized data costs space in the load module, while uninitialized
   (defaulting to zeros) does not; this may save disk space if you init
   large arrays.

2) Some loaders have an option to make any initialized data read-only,
   and thus SHARABLE.  Occasionally this can come in handy.  You can't do
   many useful things with read-only zeros...  (Yes this is of course
   non-portable but the idea is that you write your program so that it
   doesn't write to the read-only portions, so whethr they are really
   read-only doesn't matter except for efficiency.

How's that for some flammable material?

--
	Guido van Rossum, "Stamp Out BASIC" Committee, CWI, Amsterdam
	guido @ mcvax



More information about the Comp.unix.wizards mailing list