Re: Is DEFCONSTANT broken?
- From: Kaz Kylheku <kkylheku@xxxxxxxxx>
- Date: Mon, 22 Jun 2009 07:13:14 +0000 (UTC)
On 2009-06-22, Ron Garret <rNOSPAMon@xxxxxxxxxxx> wrote:
In article
<2e409792-6696-45b5-9474-636a45da86d2@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
Scott Burson <FSet.SLB@xxxxxxxxx> wrote:
On Jun 21, 6:12 pm, Ron Garret <rNOSPA...@xxxxxxxxxxx> wrote:
Actually, DEFVAR comes closest to doing what I want. But I also want to
insure that the value doesn't change or get bound.
Well, there's always DEFINE-SYMBOL-MACRO...
Doesn't work, because it doesn't insure the value won't change:
[ron@mickey:~/Desktop]$ cat test.lisp
(eval-when (:compile-toplevel :load-toplevel :execute)
(define-symbol-macro c7 '#.(gensym))
(defun c7 () c7)
Right; you get a different instance of the c7 macro when compiling and loading.
It's evaluated again, just like the initializing value of defconstant.
How about this:
;; macro only at compile time
(eval-when (:compile-toplevel)
(define-symbol-macro c7 '#.(gensym)))
;; function only available in compiled form
(eval-when (:load-toplevel)
(defun c7 () c7))
Now the problem goes away: there is /no/ C7 symbol macro when you load
the object file. And if you load the source file, there is no c7
function.
Just like in C, there are no more #define constants when you're loading .o
files. And you can't run source without compiling it. (That's not real
programming; you're supposed to edit, compile, then run, right?)
So, everything is cool.
.
- Follow-Ups:
- Re: Is DEFCONSTANT broken?
- From: Ron Garret
- Re: Is DEFCONSTANT broken?
- From: Kaz Kylheku
- Re: Is DEFCONSTANT broken?
- References:
- Is DEFCONSTANT broken?
- From: Ron Garret
- Re: Is DEFCONSTANT broken?
- From: Pascal J. Bourguignon
- Re: Is DEFCONSTANT broken?
- From: Ron Garret
- Re: Is DEFCONSTANT broken?
- From: Pascal J. Bourguignon
- Re: Is DEFCONSTANT broken?
- From: Ron Garret
- Re: Is DEFCONSTANT broken?
- From: Scott Burson
- Re: Is DEFCONSTANT broken?
- From: Ron Garret
- Is DEFCONSTANT broken?
- Prev by Date: Re: Catch/Throw in tree searching
- Next by Date: Re: Is DEFCONSTANT broken?
- Previous by thread: Re: Is DEFCONSTANT broken?
- Next by thread: Re: Is DEFCONSTANT broken?
- Index(es):
Relevant Pages
|