Loose ends: Optional

Joe Bowbeer joe.bowbeer at gmail.com
Mon Jun 3 10:03:27 PDT 2013


On Mon, Jun 3, 2013 at 3:05 AM, Remi Forax <forax at univ-mlv.fr> wrote:

> On 06/03/2013 08:11 AM, Joe Bowbeer wrote:
>
>> I'd like to see a compare-and-contrast between what is proposed for Java8
>> and Guava's Optional and Scala's Option.
>>
>> Is the criticism that Brian is fielding now a replay of prior criticism
>> of Guava's Optional?
>>
>> http://benhutchison.wordpress.**com/2012/06/05/a-rant-on-**
>> jdroids-and-wilful-ignorance/<http://benhutchison.wordpress.com/2012/06/05/a-rant-on-jdroids-and-wilful-ignorance/>
>> http://kerflyn.wordpress.com/**2011/12/05/from-optional-to-**
>> monad-with-guava/<http://kerflyn.wordpress.com/2011/12/05/from-optional-to-monad-with-guava/>
>>
>> How have Guava's user been dealing with its intentionally more limited
>> approach?
>>
>
> There are also some comments in the comment section of this wiki page:
> https://code.google.com/p/**guava-libraries/wiki/**
> UsingAndAvoidingNullExplained<https://code.google.com/p/guava-libraries/wiki/UsingAndAvoidingNullExplained>
>
> The number one criticism seems to be the lack of a method bind like in
> Haskell,
> but because Java is not Haskell, the exact operation needed is neither a
> map nor a flatMap,
> it's a composition of flatMap and Optional.ofNullable().
> So the issue is more how to deal with the return value of a method that
> can be null but that doesn't return an Optional.
>
> I still think and this is the conclusion of one of the blog cited above
> that the elvis syntax (?.)
> is the best way to deal with this issue.
> I don't see how to solve this issue without introducing
> Optional.ofNullable(), BTW.



I agree that the elvis operator seems to handle this well (based on some
limited experience).

Does everyone agree that Fugue's Option is an improvement on Guava's
Optional?

Jed Wesley-Smith et al's library also includes Either and Pair.

https://bitbucket.org/atlassian/fugue  (Is the javadoc online anywhere?)

You can see them all in action here:

https://bitbucket.org/atlassian/fugue/src/1fb9c6651708/src/test/java/com/atlassian/fugue/IterablesTest.java

--Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/lambda-libs-spec-experts/attachments/20130603/9846c00c/attachment.html 


More information about the lambda-libs-spec-experts mailing list