Difference between `set`, `setq`, and `setf` in Common Lisp?

前端 未结 6 2090
Happy的楠姐
Happy的楠姐 2020-11-30 16:53

What is the difference between \"set\", \"setq\", and \"setf\" in Common Lisp?

6条回答
  •  遥遥无期
    2020-11-30 17:21

    (set ls '(1 2 3 4)) => Error - ls has no value
    
    (set 'ls '(1 2 3 4)) => OK
    
    (setq ls '(1 2 3 4)) => OK - make ls to (quote ls) and then have the usual set
    
    (setf ls '(1 2 3 4)) => OK - same as setq so far BUT
    
    (setf (car ls) 10) => Makes ls '(10 2 3 4) - not duplicated by setq/set
    

提交回复
热议问题