Adam D. Ruppe wrote:
A non-nullable type is basically just:struct NotNull(T) { T _payload; alias _payload this; invariant() { assert(_payload !is null); } } If we could disable the default constructor, this approach might just work. Sure, the checks here would be at runtime, but you'd have them without having to manually write the assert each time.
All that does is reinvent the null pointer seg fault. The hardware does this for you for free.
A null pointer is what's known as a "white hole", all attempts to access the object are rejected.
