Option!T

Paulo Pinto pjmlp at progtools.org
Tue Dec 10 10:21:56 PST 2013


Am 10.12.2013 18:54, schrieb Yota:
> On Tuesday, 10 December 2013 at 17:28:26 UTC, Andrei Alexandrescu wrote:
>> I talked to a programmer who knows Scala (among others) and he
>> mentioned the usefulness of the Option type - a zero or one element
>> collection (range in D terminology). Here's an article discussing it:
>> http://danielwestheide.com/blog/2012/12/19/the-neophytes-guide-to-scala-part-5-the-option-type.html
>>
>
> I really came to love Option when I was working in F#.  One of the
> things I love about F# is how the language strongly discourages nulls.
> Even Anders went on video saying that he regretted making reference
> types nullable in C#.
>
> Of course, there's no way to remove the nullable-by-default nature of
> reference types in D2, but a guy can dream. =]

It would probably break a lot of code, but the Eiffel, Kottlin's 
approach could be used.

In those languages, unless it is proven that a reference type is valid 
you cannot make use of its value.

Eiffel
http://docs.eiffel.com/sites/default/files/void-safe-eiffel.pdf

Kotlin
http://confluence.jetbrains.com/display/Kotlin/Null-safety

--
Paulo


More information about the Digitalmars-d mailing list