title: LISP local/global variable assignment
body: <p>If we define a function something like</p>
  
  <pre><code>(defun foo(x)
    (setf x somevalue))
  </code></pre>
  
  <p>Is <code>x</code> defined as a local variable or global? using setf/q is setting the value to be global.
  if it is global can anyone tell me how to define a local variable in lisp other than <code>let</code>?</p>
  
  <p>Thanks!</p>
  
  <p>Consider the following example </p>
  
  <pre><code>(let ((x 0)) 
    (defun foo (y) 
      (when (equal x 0) (setq x y)) 
      (when (&lt; x y) (setq x y))
      x))
  </code></pre>
  
  <p>when I am giving some input to <code>foo</code> like <code>(foo 2)</code> , it is returning 2 and if we execute the function again with <code>(foo 1)</code> it still returns 2 and <code>(foo 3)</code> returns 3.This is what i actually want it do.But the question is how is this possible, because if I try to access the variable <code>x</code> outside the function from the clisp terminal, I am unable to.If I am accessing the function again, it seems to retain the previous value of <code>x</code>. </p>
  
  <p>thank you!</p>