lisp教程列表里面的列表

the list inside a list of lisp tutorial

我正在阅读Programming in Emacs Lisp

Here is another list, this time with a list inside of it:

     '(this list has (a list inside of it))

我对嵌套列表感到困惑,为什么它没有前缀引用

 '(this list has  '(a list inside of it))

如果 not 有前缀 `,为什么不将 a 解析为函数?

's-expression(quote s-expression) 的缩写:s-expression 中的任何内容都被视为数据,不会被计算。

所以,

'(this list has (a list inside of it))

是以下的缩写:

(quote (this list has (a list inside of it)))

包含以下列表:

(this list has (a list inside of it))

这是整个 quote 表单的值,因为它未被评估。

很容易通过写来验证这一点:

'(this list has '(a list inside of it))

如果对其进行评估,将生成以下列表作为值:

(this list has (quote (a list inside of it)))

这是 Lisp 中的一个小困难:列表是数据,也可以是程序。如果你想让一个列表成为 Lisp 程序中的数据,你需要引用它。

这样的列表:可以用 READ

阅读它们
(this list has (a list inside of it))
(this list has no list inside of it)
(+ 1 2)
(1 2 +)
(1 + 2)
(quote (this list has (a list inside of it)))
(quote (this list has (quote (a quote list inside of it))))
(quote quote)

有效的 Lisp 形式:可以用 EVAL

计算它们
(+ 1 2)
Evaluates to -> 3

(quote (+ 1 2))
Evaluates to -> (+ 1 2)

(quote (this list has (a list inside of it)))
Evaluates to -> (this list has (a list inside of it))

(quote quote)
Evaluates to -> quote

这也是一个有效的 Lisp 形式:

(quote (this list has (quote (a quoted list inside of it))))

计算结果为:

(this list has (quote (a quoted list inside of it)))