I found a Similar question.
But I don’t quite understand that explanation.
So I’m trying to run clisp with the following example:
[1]> (defvar a 5)
A
[2]> (+ a 1)
6
[3]> (defparameter b 5)
B
[4]> (+ b 1)
6
[5]> (setf c 5)
5
[6]> (+ c 1)
6
[7]> (setq d 5)
5
[8]> (+ d 1)
6
[9]> (let ((a 500)) (+ a 1))
501
[10]> (let ((b 500)) (+ b 1))
501
[11]> (let ((c 500)) (+ c 1))
501
[12]> (let ((d 500)) (+ d 1))
501
[13]>
What I found is totally the same.
I can’t figure out what’s different with them?
DEFPARAMETERalways assigns a value. So:while
DEFVARdoes it only once, so:SETFis a macro which usesSETQinternally, but has more possibilities. In a way it’s a more general assignment operator. E.g. withSETFyou can do:but you can’t do that with
SETQ: