Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Lisp语法/格式_Lisp - Fatal编程技术网

Lisp语法/格式

Lisp语法/格式,lisp,Lisp,试着用我的口齿不清。但我想知道,为什么: (defun hello(x) (print x) ) 工作很好,但是: (defun hello (x) (print(x)) ; Fails with EVAL: undefined function X. ) 不是吗?在LISPs中,会考虑非空、无引号的列表(函数、宏或特殊形式)调用 所以 是对带有参数x的print的函数调用 但是, 是对print的函数调用,其参数等于(x)的值。但是由于(x)也是非空列表,为了获得(x)的值

试着用我的口齿不清。但我想知道,为什么:

(defun hello(x)
    (print x)
)
工作很好,但是:

(defun hello (x)
    (print(x)) ; Fails with EVAL: undefined function X.
)

不是吗?

在LISPs中,会考虑非空、无引号的列表(函数、宏或特殊形式)调用

所以

是对带有参数
x
print
的函数调用

但是,


是对
print
的函数调用,其参数等于
(x)
的值。但是由于
(x)
也是非空列表,为了获得
(x)
的值,有人试图调用一个不存在的函数
x
,而不带任何参数。

关键是要注意,括号并不像在许多其他语言中那样只是对语法进行分组;它们也调用函数,类似于Python中的
X.val
X.val()
不同


因此,在本例中,您试图调用
x
,就好像它是一个函数一样。但是,根据您传递给
hello
的内容,
x
不是函数,因此无法调用。

Aha,很有趣。谢谢可能重复的
(print x)
(print (x))