sync notes(auto)
This commit is contained in:
parent
8d445f21a8
commit
c37151a727
1 changed files with 5 additions and 0 deletions
|
@ -1,6 +1,10 @@
|
||||||
# 20240428122916 setf setq defvar defparameter の違い
|
# 20240428122916 setf setq defvar defparameter の違い
|
||||||
#common_lisp #tips
|
#common_lisp #tips
|
||||||
|
|
||||||
|
そもそも・・・
|
||||||
|
defvar, defparameterはダイナミックスコープの変数(スペシャル変数)を定義する。
|
||||||
|
letや未定義時のsetfはレキシカルスコープの変数を定義する。
|
||||||
|
|
||||||
- defvar: 値が定義されていなければ定義する。上書きしようとしても存在している場合はできない。
|
- defvar: 値が定義されていなければ定義する。上書きしようとしても存在している場合はできない。
|
||||||
- defparameter: 定義されているかに関係なく定義する。すでに定義されていたら上書きする。
|
- defparameter: 定義されているかに関係なく定義する。すでに定義されていたら上書きする。
|
||||||
- setf: 定義された変数を変更するために使う。定義されていない変数を変更しようとすると、新規作成され、警告が出る。
|
- setf: 定義された変数を変更するために使う。定義されていない変数を変更しようとすると、新規作成され、警告が出る。
|
||||||
|
@ -60,5 +64,6 @@ e ; => 2
|
||||||
|
|
||||||
### Refs.
|
### Refs.
|
||||||
- [Lispで変数宣言する方法 -](https://minegishirei.hatenablog.com/entry/2023/04/17/094001)
|
- [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/)
|
- [「対話による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)
|
- [lisp - What's difference between defvar, defparameter, setf and setq - Stack Overflow](https://stackoverflow.com/a/8928038)
|
Loading…
Reference in a new issue