Option in Java 8
zhong.j.yu at gmail.com
Thu Oct 11 09:37:20 PDT 2012
It'll be a lot easier for understanding if present <==> not null.
The burden can be shifted to those who do want present and null - they
can invent a new type, so it'll be something like
Optional<Nullable<String>>. Hopefully such use cases are much rarer.
On Thu, Oct 11, 2012 at 10:32 AM, Ricky Clarkson
<ricky.clarkson at gmail.com> wrote:
> For reference, Scala's Option allows Some(null), and that's largely
> considered to be a mistake and one that hampers any potential inlining of
> Option to straight references. Functional Java's Option also allows
> some(null), but I doubt the maintainers allowed that deliberately. Guava's
> Optional rejects Optional.of(null) with a NullPointerException.
> Although one could argue that Optional does not replace null, that is a
> very common use and rejecting possibly accidental nulls would be very
> On Thu, Oct 11, 2012 at 12:16 PM, Mario Fusco <mario.fusco at gmail.com> wrote:
>> > There was a long thread on this recently on lambda-dev. You should read
>> > the archives.
>> > The implementation is currently very much an approximation. However,
>> > in mind that the goal for Option in Java may not be to create an Option
>> > monad. So the experience of other languages may or may not be
>> Thank you Brian,
>> I gave a read to that thread, but I have to say it is still not completely
>> clear to me what's the final goal of that Optional class indeed.
>> The only other (ugly) thing I discovered is that it should allow something
>> like a Some(null) that sounds really wrong to me or at least makes me think
>> even more that I have not understood the purpose of that class.
>> If you will give a quick read to the article I linked in my former email,
>> it would be great if you will let me know what you think about it and
>> mostly how my interpretation of the Option monad is far from what you have
>> in mind.
>> Thanks again,
More information about the lambda-dev