在emacs lisp中对`nil`进行操作

时间:2012-12-28 10:04:51

标签: emacs lisp elisp

这样的表达式会导致错误

(= nil 3)


Debugger entered--Lisp error: (wrong-type-argument number-or-marker-p nil)
=(nil .......

那么有一种简单的方法(例如,另一个名为my-eq的函数)使这个表达式返回nil(意味着False),如下所示:

(my-eq nil 3)
=> nil

1 个答案:

答案 0 :(得分:3)

那是eqequal

(eq 3 nil)

=>零

(eq OBJ1 OBJ2)

Return t if the two args are the same Lisp object.

(equal O1 O2)

Return t if two Lisp objects have similar structure and contents.
They must have the same data type.
Conses are compared by comparing the cars and the cdrs.
Vectors and strings are compared element by element.
Numbers are compared by value, but integers cannot equal floats.
 (Use `=' if you want integers and floats to be able to be equal.)
Symbols must match exactly.