sync notes(auto)

This commit is contained in:
Kaz Saita(raspi5) 2024-04-28 12:45:03 +09:00
parent 8d445f21a8
commit c37151a727

View file

@ -1,6 +1,10 @@
# 20240428122916 setf setq defvar defparameter の違い
#common_lisp #tips
そもそも・・・
defvar, defparameterはダイナミックスコープの変数(スペシャル変数)を定義する。
letや未定義時のsetfはレキシカルスコープの変数を定義する。
- defvar: 値が定義されていなければ定義する。上書きしようとしても存在している場合はできない。
- defparameter: 定義されているかに関係なく定義する。すでに定義されていたら上書きする。
- setf: 定義された変数を変更するために使う。定義されていない変数を変更しようとすると、新規作成され、警告が出る。
@ -60,5 +64,6 @@ e ; => 2
### Refs.
- [Lispで変数宣言する方法 -](https://minegishirei.hatenablog.com/entry/2023/04/17/094001)
- [Lispのダイナミック・スコープとスペシャル変数 · wshito's diary](https://diary.wshito.com/comp/lisp/dynamic-scope/)
- [「対話によるCommon Lisp入門」第2話まとめート · wshito's diary](https://diary.wshito.com/comp/lisp/cl-dialogue/2/)
- [lisp - What's difference between defvar, defparameter, setf and setq - Stack Overflow](https://stackoverflow.com/a/8928038)