[comp.emacs] GNU Emacs variable initialization.

aj@zyx.UUCP (Arndt Jonasson) (04/27/87)

There is a bug regarding the order of initialization of Lisp variables in
GNU Emacs version 17.62.

In the file alloc.c, the function 'init_alloc_once' uses Qt to initialize
the variable 'Vpurify_flag'. In the file lread.c, t and nil are created and
assigned to Qt and Qnil, respectively.

In the file editfns.c, 'Vpurify_flag' is checked, and the user name, login
name etc. stuff is not done if 'Vpurify_flag' isn't equal to Qnil, thus
deferring that to the time when the dumped Emacs starts, when 'Vpurify_flag'
will have been set to Qnil (done in emacs.c, Lisp function 'dump-emacs').

The init routines for these files are run in this order:

init_alloc_once		in alloc.c
init_obarray		in lread.c
init_editfns		in editfns.c

Thus, Qt is used before it is defined, which isn't really good programming
style. It happens to work almost everywhere, since the bit pattern that Qt
has before it is set in lread.c is most probably not the future value of
Qnil (in fact, it is probably zero).

This became a problem when I wanted to make the user name, login name etc.
available on Emacs on Apollo, which as you may know doesn't support dumping
of Emacs. Thus, 'Qverify_flag' is always t, when actually it should always be
nil. I changed the 'Qverify_flag = Qt' in 'init_alloc_once' to set it to t
in case CANNOT_DUMP was defined. Because of the situation outlined above, this
didn't work, since Qnil at the time when 'Qverify_flag' was tested and when
it was defined were two different things.

So, the double fix is to remove the 'Qverify_flag = Qt' and related
declarations from alloc.c, and put into 'init_obarray' in lread.c the lines

#ifdef CANNOT_DUMP		/* Run as if started from dump in case we */
  Vpurify_flag = Qnil;		/* can't dump out (Apollo). */
#else				/* This was moved from alloc.c. */
  Vpurify_flag = Qt;
#endif

after the setting of Qnil and Qt.

This may have been fixed in GNU Emacs version 18. It is only of interest to
users of Apollo releases earlier than 9.5 (there was a recent posting
stating that dumping of Emacs works on Apollo release 9.5).
-- 
Arndt Jonasson, ZYX Sweden AB, Styrmansgatan 6, 114 54 Stockholm, Sweden
UUCP: ...!seismo!mcvax!enea!zyx!aj