Option in Java 8
ricky.clarkson at gmail.com
Thu Oct 11 08:32:16 PDT 2012
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