LISP 列表和范式

标签 lisp eval normalization evaluation lambda-calculus

一些 LISP 表达式对自身求值(例如 MIT-Scheme REPL,尽管 GNU Common Lisp 同意):

1 ]=> 3
;Value: 3

并且是正常形式。因此,表达式的求值(例如 (+ 2 1))可以恰本地称为转换为正常形式。这很好,因为这就是我一直以来正式理解评估的方式。

但是对于列表我们有麻烦了:

1 ]=> (list 3 2)
; Value 16: (3 2)
1 ]=> (3 2)
;The object 3 is not applicable.
;To continue, call RESTART with an option number:
; (RESTART 2) => Specify a procedure to use in its place.
; (RESTART 1) => Return to read-eval-print level 1.

我的想法是否正确:

  1. (many[0]) 个 LISP 没有(非空)列表的规范形式,并且
  2. (许多)LISP 不具有求值归约到范式的特性?

如果是这样,这是否与抽象重写系统等 PLT 中的形式主义有些矛盾?在 LISP 中捕获评估的替代形式有哪些?


[0] 或者更准确地说,是“大多数著名的 LISP”,例如 CL、Clojure 和 Scheme。但我会对鲜为人知的反例感兴趣!

最佳答案

Lisp 只能根据几个原始运算符来定义。 How many primitives does it take to build a LISP machine? Ten, seven or five?因此,您可以认为从扩展到它们所获得的内容有一个正常形式。

但是 Lisp 不是 lambda 演算。 What type of lambda calculus would Lisp loosely be an example of?

Lisp wasn't designed to be like the lambda calculus :

To use functions as arguments, one needs a notation for functions, and it seems natural to use the lambda-notation of Church. I didn’t understand the rest of the book, so I wasn’t tempted to try to implement his more general mechanism for defining functions.
-- History of Lisp, Stanford AI Laboratory memo 1979 by J. McCarthy, page 6

关于LISP 列表和范式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42166825/

相关文章:

r - `[.` `ReferenceClass` 方法

bash - 找出哪个 shell tcsh/bash/etc。在脚本上使用 eval 时正在运行

ruby - $SAFE = 4 和定时执行限制是否足以防止 eval 在 Ruby 中的安全漏洞?

python - 按百分比标准化滚动窗口(pandas)

google-sheets - 不使用 Excel 对 Tableau 的交叉表数据进行标准化(重新格式化)

function - 在 Common Lisp 中将 - 更改为 +

emacs - 如何编辑 quicklisp 的系统定义文件

python - 如何使用 python 规范化原始音频文件

lisp - 在 Clozure Cl 中处理图像

lisp - 在 Emacs Lisp 中获取指向列表元素的指针