Do all programming languages have a clear concept of NIL, null, or undefined?-Record and share programming errors

This is a type system question, so anyone who answers “0” misses the point.

What you’re talking about is a sum type (check “Types and Programming Languages”).

That is, a type that has n + 1 inhabitants. That is, the type whose elemens are:

  • all the values of the type you care about

OR

This is easily described as an algebraic data type, e.g. in Haskell

data Maybe a = Just a | Nothing

Bizarrely, relatively few languages support sum types, so they encode them as products (a pair of the tag Just or Nothing, and the value itself) or by overloading one of the inhabitants of the type (e.g. -1 or 0 becomes Nothing).

This type is usually known as Maybe or Optional.

Originally posted 2013-08-31 08:13:57.