Re: How to use constants in a case key form ?
- From: Willem Broekema <metawilm@xxxxxxxxx>
- Date: Fri, 23 Nov 2007 16:53:56 -0800 (PST)
On Nov 23, 9:41 pm, Zach Beane <x...@xxxxxxxx> wrote:
Geoff Wozniak <geoff.wozn...@xxxxxxxxx> writes:
This assumes that the constants are available when the case form is
read. It also assumes you recompile the forms that depend on the
constants if you change the constants.
This is important to remember. I use the #.+FOO+ form all the time,
but CLISP needs an EVAL-WHEN around the defconstant form to ensure the
value is visible at compile-time.
This sounds wrong to me. The form prefixed by #. is evaluated at read
time, not compile time. If the constant's value should be known at
read time, the defconstant form must have been evaluated at read time
- and there is no eval-when clause for that.
I think the following is an appropriate way to define a constant and
use its value as case clause value, both in the same file:
(progn #.(progn #1=(defconstant +foo+ 1) nil) ;; declare constant at
read time; nil as harmless result
#1#) ;; also have the normal effect of defconstant
(defun f (x)
(case x
(#.+foo+ 42)))
- Willem
.
- Follow-Ups:
- Re: How to use constants in a case key form ?
- From: Zach Beane
- Re: How to use constants in a case key form ?
- References:
- How to use constants in a case key form ?
- From: Frank Goenninger DG1SBG
- Re: How to use constants in a case key form ?
- From: Geoff Wozniak
- Re: How to use constants in a case key form ?
- From: Zach Beane
- How to use constants in a case key form ?
- Prev by Date: Re: Macros vs. passing anonymous functions, argumentation
- Next by Date: standard keyboard character?
- Previous by thread: Re: How to use constants in a case key form ?
- Next by thread: Re: How to use constants in a case key form ?
- Index(es):