Skip to content

Instantly share code, notes, and snippets.

@zhouqiang-cl
Created December 4, 2016 04:23
Show Gist options
  • Save zhouqiang-cl/733e321ade2c5efa6b554467a7a3ead0 to your computer and use it in GitHub Desktop.
Save zhouqiang-cl/733e321ade2c5efa6b554467a7a3ead0 to your computer and use it in GitHub Desktop.
common lisp 的访问器 GET
语法
get symbol indicator &optional default => value
(setf (get symbol indicator &optional default) new-value)
参数和值
symbol --- 一个 symbol
indicator --- 一个 object
default --- 一个 object, 默认为 nil
value --- 如果指明的属性存在, 则这个 object的属性是value, 否则, 是默认的属性
new-value --- 一个 object
描述
get 获取 object 的属性
代码
* (defvar man (gensym "MAN"))
MAN
* (get man 'wife)
NIL
* (setf (get man 'wife) "WIFE")
"WIFE"
* (get man 'wife)
"WIFE"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment