0

I tried using setf in the "toplevel" of my program:

(setf x 17)

But SBCL version 1.3.1 gives me an error message:

; in: SETF X
;     (SETF X 17)
; ==>
;   (SETQ X 17)
; 
; caught WARNING:
;   undefined variable: X
; 
; compilation unit finished
;   Undefined variable:
;     X
;   caught 1 WARNING condition

It sounds like I should have declared x somewhere but I don't know how to do that.

hugomg
  • 68,213
  • 24
  • 160
  • 246
  • 1
    You want [**defvar** and **defparameter**](http://www.lispworks.com/documentation/HyperSpec/Body/m_defpar.htm). Once you have those terms to search for, you'll find lots of information here on Stack Overflow (and other places, too). – Joshua Taylor Feb 22 '16 at 20:46
  • Maybe this could be closed as a duplicate of [setq and defvar in lisp](http://stackoverflow.com/questions/3855862/setq-and-defvar-in-lisp), or [What's difference between defvar, defparameter, setf and setq](http://stackoverflow.com/questions/8927741/whats-difference-between-defvar-defparameter-setf-and-setq), or [Assigning variables with setf, defvar, let and scope](http://stackoverflow.com/questions/14314834/assigning-variables-with-setf-defvar-let-and-scope). – Joshua Taylor Feb 22 '16 at 20:47
  • [In Lisp, how do I fix “Warning: Assumed Special?”](http://stackoverflow.com/questions/3860866/in-lisp-how-do-i-fix-warning-assumed-special) is actually very similar, in that it starts from a similar warning. – Joshua Taylor Feb 22 '16 at 20:49

0 Answers0