一个函数的参数,我指的是X和ÿ在
(defun my-function (x y ) body)
Run Code Online (Sandbox Code Playgroud)
有时也称为局部变量或局部参数或形式参数甚至参数.所有这些术语在Lisp中是否真的正确?另一个术语更适合吗?
此外,有人说函数的参数绑定到正在调用的函数的参数的值.这个术语" 必然 "是否正确?或者我们是否必须说它们将" 具有 "函数参数的" 值 "?
是否有人说全球符号" 与价值相关 "或" 具有价值 "?我在书中读到这引起了巨大的混乱.在该书中,建议" 绑定 "一词不应用于全局符号,而应仅用于函数的参数.但另一方面,构建函数的边界就像在
(boundp 'x))
Run Code Online (Sandbox Code Playgroud)
在Lisp中也用于全局符号.这表明符号不是" 有价值 ",而是" 与价值联系在一起 "?
Common Lisp使用这个术语:
函数具有已定义的参数列表.
函数调用的评价增加了一个结合各参数与对应的值从参数到当前词法环境.
全局变量在全球环境中具有约束力.
参考
请参阅Common Lisp HyperSpec(ANSI Common Lisp标准的HTML变体),以及评估/编译和词汇表的章节.该文档描述了对Common Lisp有用的术语.其他Lisp方言(Emacs Lisp,ISLisp,Visual Lisp,......)可能有不同的术语.
例
(defun foo (a b)
(bar a b a b))
Run Code Online (Sandbox Code Playgroud)
以上功能在评论中说明:
(defun foo ; <- the name of the global function is foo
(a b) ; <- the list of parameters of the function foo
; <- in the body, a and b are bound
; in the body there is one function call form
(bar ; <- the function bar gets called
a b a b) ; <- the arguments to be evaluated
)
Run Code Online (Sandbox Code Playgroud)