为什么在Common Lisp中冒号先于变量 [英] Why colons precede variables in Common Lisp
问题描述
Common Lisp中的冒号在变量前的语法是什么意思?我已经看过这样的程序了,在这里,我将介绍大量函数中的一些示例代码.
What does the syntax, colons preceding variable in Common Lisp, mean? I've seen programs with such, and I'll present some sample code here, out of a large set of functions.
(defun expand (successorf node)
(mapcar (lambda (action-state-cost)
(let ((action (car action-state-cost))
(state (cadr action-state-cost))
(cost (caddr action-state-cost)))
(make-node :state state :parent node
:action action :path-cost (+ (node-path-cost node) cost)
:depth (1+ (node-depth node)))
))
(funcall successorf (node-state node))
))
推荐答案
实际上,它们不是变量;这些是关键字.它们是一种特殊的有效令牌,类似于其他语言中的原子".这是将命名(几乎总是可选)参数传递给函数调用的便捷内置方法.
They're not variables, actually; those are keywords. They're a special kind of efficient token, similar to "atoms" in other languages. It's a convenient, built-in way to pass named (and, almost always, optional) parameters into a function call.
http://www.gigamonkeys.com/book/functions.html 描述函数调用的语法.
http://www.gigamonkeys.com/book/functions.html describes the syntax of function calls.
这篇关于为什么在Common Lisp中冒号先于变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!