Optional<T> equivalent in D?

Max Klyga email at domain.com
Sat Nov 16 02:41:50 PST 2013


On 2013-11-16 05:04:20 +0000, Jonathan M Davis said:

> I really don't understand this. Optional<T> is one of the most useless ideas
> that I've ever seen in Java. Just use null.

Optional specifies explicitly that value can be absent and forces 
client to check before using the value.
Also, if Optional implements monadic interface one can easily chain 
computations depending on the state of optional values.

Even if references are nullable by default users do not check them for 
null on every usage. NullPointerException and the like are almost 
always indicators of programming error.

Null is just horrible.



More information about the Digitalmars-d-learn mailing list