-
Notifications
You must be signed in to change notification settings - Fork 32
WhyOrderMatters
Felix S. Klock II edited this page Jul 28, 2013
·
1 revision
This page is dedicated to documentation of why sometimes the order of elements in some definition is actually significant even though you might not realize so.
-
Lib/makefile.sch
: Thecommon-heap-files
definition lists all the components that we will load in the bootstrap heap. We actually run the code for each in order. So if one file uses a variable defined by another file, you better make sure you get the order right.- This matters because, for example, if you try to define a macro in
Compiler/usual.sch
that uses a transformer macro, you'll get the mysterious error on startup that no callout vector is defined. - The reason this happens is that the expander is going to call
eval
on a transformer macro, and not only haseval
not been defined, but the error handling machinery for telling you thateval
is undefined hasn't even been set up yet. - The current strategy for dealing with this (that is, for making a transformer macro that is part of the "standard" distribution) is to arrange things so that we delay the macro definition until after all of our machinery has been setup. We do this by pushing a quoted macro definition onto the variable
*interactive-eval-list*
. - Note however that
*interactive-eval-list*
is defined inLib/Common/toplevel.sch
, which occurs relatively late in the order defined inLib/makefile.sch
. (Agh! Order matters!) So you need to make sure that if you're going to use this trick, that you only do it in heap files that are loaded after"toplevel"
- This matters because, for example, if you try to define a macro in