谷歌搜索但没有找到答案。
nil 这个名字有什么特别的吗?
nil的概念和其他语言中的null有什么不同吗?
好吧,“nil”是 Lisp 和 Smalltalk 中“无”具体化概念的传统名称†。 “null”一词用作形容词,意思是“空”,如“空列表”,即 nil。
同时,“null”传统上是 C 中的指针值,表示该指针不指向任何有效的内容。它指的是指针为 null 的事实(与 Lisp 使用该词的含义相同),但它本身被认为是一个值。
Matz 是 Smalltalk 和 Lisp 的粉丝,所以他采用了它们的术语。这两个术语之间的含义并没有真正的重要区别——其中一个只是 C 语言。
† Actually, "nil" existed in a lot more languages than just those. Even Algol-68, the great granddaddy of C, called it "nil". I'm not sure if C invented "null" as the name for the null reference or just popularized it, but I'm pretty sure that all the modern languages using that term got it from C.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)