我遇到了以下代码片段:
(defstructure object
"An object is anything that occupies space. Some objects are 'alive'."
(name "?") ; Used to print the object on the map
(alive? nil) ; Is the object alive?
(loc (@ 1 1)) ; The square that the object is in
(bump nil) ; Has the object bumped into something?
(size 0.5) ; Size of object as proportion of loc
(color 'black) ; Some objects have a color
(shape 'rectangle) ; Some objects have a shape
(sound nil) ; Some objects create a sound
(contents '()) ; Some objects contain others
(max-contents 0.4) ; How much (total size) can fit inside?
(container nil) ; Some objects are contained by another
(heading (@ 1 0)) ; Direction object is facing as unit vector
)
我不确定@在这里表示什么。我已经搜索了其余的代码,看看它是否被定义为一个函数但是却找不到任何东西。我的问题,是“@”常用lisp的一些常用实现的一部分,还是这个代码具体?感谢。
链接到文件: https://github.com/aimacode/aima-lisp/blob/master/agents/environments/grid-env.lisp
答案 0 :(得分:7)
该功能在utilities/utilities.lisp
:
(defun @ (x y) "Create a 2-D point" (make-xy :x x :y y))
它创建一个点(或矢量)。
为了找到定义,我不得不克隆存储库,因为GitHub搜索在搜索代码时几乎没用:
find -name "*.lisp" -exec grep -H @ {} \;
...
./utilities/utilities.lisp:(defun @ (x y) "Create a 2-D point" (make-xy :x x :y y))
...
我没有搜索defun
,因为它也可能是一个宏。
答案 1 :(得分:3)
使用Lisp IDE
您可以使用通常的Lisp开发环境工具在源代码中导航。
然后打开包含源定义的文件,并将光标放在相关代码上。