Created
December 20, 2016 08:05
-
-
Save zhouqiang-cl/adf2b6aebc3b62f726da979037174368 to your computer and use it in GitHub Desktop.
common lisp 的访问器 GET
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
语法 | |
get symbol indicator &optional default => value | |
(setf (get symbol indicator &optional default) new-value) | |
参数和值 | |
symbol --- 一个 symbol | |
indicator --- 一个 object | |
default --- 一个 object, 默认为 nil | |
value --- 如果 指定的属性存在, 则返回该属性的值. 否则返回 default 的值 | |
new-value --- 一个 object | |
描述 | |
返回 symbol 的属性的值 | |
代码 | |
* (setf test (make-symbol "test")) | |
#:|test| | |
* (get test 'age) | |
NIL | |
* (get test 'age 18) | |
18 | |
* (setf (get test 'age) 25) | |
25 | |
* (get test 'age 18) | |
25 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment