From ... Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!news.tele.dk!148.122.208.68!news2.oke.nextra.no!nextra.com!news01.chello.no!Norway.EU.net!127.0.0.1!nobody From: Erik Naggum Newsgroups: comp.lang.lisp Subject: Re: Q: example usage of EVAL-WHEN Date: 30 Oct 2000 10:45:37 +0000 Organization: Naggum Software; vox: +47 800 35477; gsm: +47 93 256 360; fax: +47 93 270 868; http://naggum.no; http://naggum.net Lines: 41 Message-ID: <3181891537734338@naggum.net> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: oslo-nntp.eunet.no 972903603 8455 195.0.192.66 (30 Oct 2000 11:00:03 GMT) X-Complaints-To: newsmaster@eunet.no NNTP-Posting-Date: 30 Oct 2000 11:00:03 GMT mail-copies-to: never User-Agent: Gnus/5.0803 (Gnus v5.8.3) Emacs/20.7 Xref: supernews.google.com comp.lang.lisp:2879 * 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