Subject: Re: Q: example usage of EVAL-WHEN From: Erik Naggum <erik@naggum.net> Date: 30 Oct 2000 10:45:37 +0000 Newsgroups: comp.lang.lisp Message-ID: <3181891537734338@naggum.net> * xenophon@irtnog.org (Xenophon Fenderson the Carbon(d)ated) | I have text parsing code that looks something like the following: | | (defparameter *the-default-macro-table* (make-hash-table)) | | ;; here is some code to initialize *the-default-macro-table* | (setf (gethash #\a *the-default-macro-table*) #'process-\a) | (setf (gethash #\b *the-default-macro-table*) #'process-\b) If these pieces of code are always executed together, it would perhaps look better if you did something like this: (defparameter *the-default-macro-table* (let ((hash-table (make-hash-table))) (setf (gethash #\b hash-table) #'process-\b) (setf (gethash #\b hash-table) #'process-\b) hash-table)) | I would like the hash table (along with its initial entries) to be | re-created each time the file is loaded. This is what defparameter does. | Do I have to use EVAL-WHEN to get the behavior I want? No. | When should I use EVAL-WHEN? | | When shouldn't I use EVAL-WHEN? These are almost impossibly broad questions. You should use eval-when when evaluation is to occur at other times than the defaults. You should not use eval-when when the default is sufficient or if you don't understand when to use eval-when... #:Erik -- Does anyone remember where I parked Air Force One? -- George W. Bush