Nulls

Doug Lea dl at cs.oswego.edu
Sun Sep 23 06:58:31 PDT 2012


On 09/23/12 09:54, Tim Peierls wrote:

>
> People shouldn't be mapping to null in the first place, any more than they
> should be mapping to NaN.

Yes. (This has been my stance for about 25 years straight :-)

>
>     But the issues make it impossible to write some generic
>     Map utilities because the need to recheck forces non-atomicity.
>
>     For findAny etc, the issue is even harder:
>        if (!...findAny(...).isPresent())
>          // somehow recheck?
>     And the need for recheck is even less obvious.
>
>
> So unobvious that I still don't see it. As long as you aren't treating null as
> an acceptable value in Streams or as the contents of an Optional, why do you
> need to re-check?
>

Suppose there are two elements that match predicate, one null, one
nonnull. And suppose the findAny implementation finds the null one
first and so reports an absent Optional.

-Doug




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