Optional<T> equivalent in D?
Ary Borenszweig
ary at esperanto.org.ar
Sat Nov 16 10:36:03 PST 2013
On 11/16/13 7:41 AM, Max Klyga wrote:
> 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.
Null is only horrible if the compiler let's you dereference it...
something that happens in almost every language out there.
More information about the Digitalmars-d-learn
mailing list