[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: What's wrong here?
- To: clisp-list@ma2s2.mathematik.uni-karlsruhe.de
- Subject: Re: What's wrong here?
- From: Bernt Nilsson <bkn@ida.liu.se>
- Date: Wed, 28 Apr 93 09:09:49 +0200
> Given these two definitions:
>
> (defstruct flugblog
> (color 'blue)
> (size 'huge))
>
> (defun foo ()
> ;;
> ;; Returns the color of a newly-constructed, temporary flugblog
> ;;
> (let ((x (make-flugblog)))
> (eval '(flugblog-color x))))
>
> CLISP chokes on (foo). It complains that x has no value. I've
stepped
> through this problem, and it seems to have something to do with the
call
> to EVAL. Any clues?
Yes, "x" is not declared special.
Quoting CLtL 2:
"eval form [Function]
The form is evaluated in the current dynamic environment and a null
lexical environment."
- You can eigther use a local or a global special declaration:
Modify foo;
(let ((x (make-flugblog)))
(declare (special x))
(eval '(flugblog-color x))))
Or evaluate "(defvar x)" before running (or compiling) foo.
-- Bernt
----------------------------------------------------------------------
Bernt Nilsson, Systems Manager | Internet: BKN@IDA.LIU.SE
IDA, LiTH (CS Dept. Linkoping U) | uucp: ...!sunic!liuida!bkn
S-581 83 Linkoping, Sweden | Bitnet: BKN@SELIUIDA
Phone +46 13 281975