10.2.7 特殊表达式(DONE)

特殊表达式通常是基础函数,因此其参数可能,也可能不会被求值。大多数的特殊表达式有它们自己的控制结构,变量绑定,这是常规函数无法做到的。

每个特殊表达式都有它们自己的求值规则,甚至有些参数是否求值,取决于另一个参数的求值结果。

如果非空列表的第一个符号被解释为特殊表达式,那么这个列表会被按照该特殊表的规则进行求值;如果没有特殊表达式,Emacs 的行为将无法被良定义(即便不会出现数学上的冲突)。举个例子,((lambda (x) x . 3) 4) 包含了一个子表达式,这个子表达式以 lambda 开头,但并不是一个良定义的 lambda 表达式,因此 Emas 可能会抛出错误,也可能会返回 3, 或 4 或 nil,或者出现其他意想不到的行为。

Function: special-form-p object

这个谓语测试了参数object是否为特殊表达式,如果是则返回 t,否则返回 nil。

这里有一个依照字母顺序排列的表,列举了 Emcas Lisp 中所有的特殊表达式。

and

see Combining Conditions

catch

see Catch and Throw

cond

see Conditionals

condition-case

see Handling Errors

defconst

see Defining Variables

defvar

see Defining Variables

function

see Anonymous Functions

if

see Conditionals

interactive

see Interactive Call

lambda

see Lambda Expressions

letlet*

see Local Variables

or

see Combining Conditions

prog1prog2progn

see Sequencing

quote

see Quoting

save-current-buffer

see Current Buffer

save-excursion

see Excursions

save-restriction

see Narrowing

setq

see Setting Variables

setq-default

see Creating Buffer-Local

unwind-protect

see Nonlocal Exits

while

see Iteration

Common Lisp note:在 GNU Emcas Lisp 和 Common Lisp 中特殊表达式有一些不同。setq,if 和 catch 是两者中都有的特殊表达式。但 save-excursion 是 Emcas Lisp 中独有的特殊表达式;throw 是 Common Lisp 中特有的特殊表达式(因为 Common Lisp 允许抛出多个值,而Emcas Lisp 中没有这个概念)

最后更新于