LISP local/global variable assignment

后端 未结 3 1328
情话喂你
情话喂你 2021-02-08 14:02

If we define a function something like

(defun foo(x)
  (setf x somevalue))

Is x defined as a local variable or global? using setf/

3条回答
  •  伪装坚强ぢ
    2021-02-08 14:41

    In your code x is a parameter to the f function and thus local to the function. The call to setf does not create new variable, but simply sets the value of the existing local variable x. Using setq instead of setf would behave the same.

提交回复
热议问题