Difference between SET, SETQ and SETF in LISP

SET  can set the value of  symbols ;
 
SETQ  can set the value of  variables ;
 
SETF  is a  macro  that will call different function depending on what was called as its first argument.
 
examples
 
(set (quote l) '(1 2 3))
(1 2 3)
 
 
(set l '(1 2 3))
Failure, l must be a symbol.
 
 
(set 'l '(1 2 3))
(1 2 3)
 
 
(setq l '(1 2 3))
(1 2 3)
 
 
(setq (car l) 10)
Failure.
 
 
(setf l '(1 2 3))
(1 2 3)
 
 
(setf (car l) 10)

 

l is (10 2 3)
相關文章
相關標籤/搜索