In a part of my source, I have a definition like this :
(defvar *ALIAS-DATABASE* '(...))
I have a macro build-system-init which takes this variable and then
processes it, like this :
=== Code
(build-system-init *ALIAS-DATABASE* ...)
(defmacro build-system-init (alias-list connection-list function-name)
`(progn
,@(create-aliases alias-list)
,(export-aliases alias-list)
,(create-init-function
alias-list
connection-list
function-name)))
(defun create-aliases (list)
(mapcar 'create-accessor-function (symbol-value list)))
(defun alias-names (list)
(mapcar (lambda (element) (second element)) (symbol-value list)))
=== End code
However, when I try to compile the file in which the variable is
defined and the macro used, I get a message :
*** - SYMBOL-VALUE: *ALIAS-DATABASE* does not have a dynamic value.
I have tried by replacing defparameter with defvar, this does not
work.
Doing (declaim (special *alias-database*)) does not work either.
I think I know what is going, since it is a macro which is processed
at compile-time, variables do not have a value at that point.
What solution is there for my problem ?
Regards,
Jurgen
In article <························@o11g2000prd.googlegroups.com>,
jurgen_defurne <··············@pandora.be> wrote:
> In a part of my source, I have a definition like this :
>
> (defvar *ALIAS-DATABASE* '(...))
>
> I have a macro build-system-init which takes this variable and then
> processes it, like this :
>
> === Code
>
> (build-system-init *ALIAS-DATABASE* ...)
>
> (defmacro build-system-init (alias-list connection-list function-name)
> `(progn
> ,@(create-aliases alias-list)
> ,(export-aliases alias-list)
> ,(create-init-function
> alias-list
> connection-list
> function-name)))
>
> (defun create-aliases (list)
> (mapcar 'create-accessor-function (symbol-value list)))
>
> (defun alias-names (list)
> (mapcar (lambda (element) (second element)) (symbol-value list)))
>
> === End code
>
> However, when I try to compile the file in which the variable is
> defined and the macro used, I get a message :
>
> *** - SYMBOL-VALUE: *ALIAS-DATABASE* does not have a dynamic value.
>
> I have tried by replacing defparameter with defvar, this does not
> work.
>
> Doing (declaim (special *alias-database*)) does not work either.
>
> I think I know what is going, since it is a macro which is processed
> at compile-time, variables do not have a value at that point.
>
> What solution is there for my problem ?
>
> Regards,
>
> Jurgen
See EVAL-WHEN.
Or define the variable in another file and compiler/load
that one first.
--
http://lispm.dyndns.org
On Jun 4, 11:29 am, Rainer Joswig <······@lisp.de> wrote:
> In article <························@o11g2000prd.googlegroups.com>,
>
>
>
> jurgen_defurne <··············@pandora.be> wrote:
> > In a part of my source, I have a definition like this :
>
> > (defvar *ALIAS-DATABASE* '(...))
>
> > I have a macro build-system-init which takes this variable and then
> > processes it, like this :
>
> > === Code
>
> > (build-system-init *ALIAS-DATABASE* ...)
>
> > (defmacro build-system-init (alias-list connection-list function-name)
> > `(progn
> > ,@(create-aliases alias-list)
> > ,(export-aliases alias-list)
> > ,(create-init-function
> > alias-list
> > connection-list
> > function-name)))
>
> > (defun create-aliases (list)
> > (mapcar 'create-accessor-function (symbol-value list)))
>
> > (defun alias-names (list)
> > (mapcar (lambda (element) (second element)) (symbol-value list)))
>
> > === End code
>
> > However, when I try to compile the file in which the variable is
> > defined and the macro used, I get a message :
>
> > *** - SYMBOL-VALUE: *ALIAS-DATABASE* does not have a dynamic value.
>
> > I have tried by replacing defparameter with defvar, this does not
> > work.
>
> > Doing (declaim (special *alias-database*)) does not work either.
>
> > I think I know what is going, since it is a macro which is processed
> > at compile-time, variables do not have a value at that point.
>
> > What solution is there for my problem ?
>
> > Regards,
>
> > Jurgen
>
> See EVAL-WHEN.
>
> Or define the variable in another file and compiler/load
> that one first.
>
> --http://lispm.dyndns.org
Thanks, a little bit of experimenting and my problem is solved.
With a large language like CL, one needs sometime to be pointed in the
right direction.
As a result, my simulation in CLISP now runs 25 times faster because
of proper byte-code compilation.
Regards,
Jurgen