I am interested in how nil
used in various programming languages, and in general how convenient it is from the point of view of language design.
This topic discusses exclusively dynamically typed languages.
For example, in JavaScript there are two values similar to nil
: null
and undefined
. (Was it necessary to produce?)
The Scheme has #f
, but no nil
. In Factor , there is no nil
either, and they use f
. (Does nil
need to be false
?)
In addition, I somehow read that in the first versions of Objective-C, there was a nil
object (Objective-C I don’t know at all), which absorbed calls, was a black hole. Those. behaved like NaN for numbers. On any message, the object returned nil
.
How permissible is it to treat "empty" objects (empty list, empty dictionary, etc.) as false
, and whether such a feature has dangerous side effects, or is it at all a location for any bugs.
Welcome:
- Links to articles with an overview of various approaches
- Links to any interesting languages related to the topic.
- Discussion of various approaches, convenience and hazards of use
(if () 'true 'false) => 'false
, also a case to consider. - Vladimir GordeevNull, null, Nil, Nothing, None
peacefully coexist in it. And all these are different things. - Nofate ♦