Void safety


Void safety is a guarantee within an object-oriented programming language that no object references will have null or void values.
In object-oriented languages, access to objects is achieved through references. A typical call is of the form:
x.f
where f denotes an operation and x denotes a reference to some object. At execution time, however, a reference can be void. In such cases, the call above will be a void call, leading to a run-time exception, often resulting in abnormal termination of the program.
Void safety is a static guarantee that no void calls will ever arise.

History

In a 2009 talk, Tony Hoare traced the invention of the null pointer to his design of the Algol W language and called it a "mistake":
Bertrand Meyer introduced the term "void safety".

In programming languages

An early attempt to guarantee void safety was the design of the Self programming language.
The Eiffel language is void-safe according to its ISO-ECMA standard; the void-safety mechanism is implemented in EiffelStudio starting with and using a modern syntax starting with .
The Spec# language, a research language from Microsoft Research, has a notion of "non-nullable type" addressing void safety.
The F# language, a functional-first language from Microsoft Research running on.NET framework, is void-safe except when interoperating with other.NET languages.
The C# language implements compile-time null safety check since version 8. However, to stay compatible with anterior versions of the language, the feature is opt-in on a per project or per file basis.
The Kotlin language, a JVM language, and Apple's Swift language use null-safe types by default.