nullとnilの違い
実用CommonLispの以下のコードを書いていて、そういえばnullとnilの違いってなんぞや?って思い調べてみた。
(defun mappend (fn the-list) "Apply fn to each element of list and append the results." (if (null the-list nil (append (funcall fn (first the-list)) (mappend fn (rest the-list)))))
http://「NULL」と「NIL」の違いを教えてください。 どちらも「無い」みたい
両者は「品詞」が異なります。 どちらも「何もない」というような意味ですが、nullusは代名詞的形容詞といって他の名詞などを修飾するときに使います。(=英語の No news などの「no」に相当) nilは名詞「無」(=nothing)または副詞「決して...でない」(=never)といった使われ方をします。
へぇー!だからヌル判定はnullで値としてのヌルはnilなんだ。勉強になりました。