Tim Peierls tim at
Fri Sep 21 10:16:46 PDT 2012

On Fri, Sep 21, 2012 at 12:36 PM, Brian Goetz <brian.goetz at>wrote:

> But this leaves us with now three ways of saying "no value"
>  - reference to Optional is null
>  - Optional is empty
>  - Optional is not empty but contains null
> And this just kicks the NPE can down the street.

Which would vitiate the main reason to introduce Optional in the first
place. I like Optional and would hate to see it gutted this way.

I want to eat my cake and have it, too:

   1. Outlaw null from collections (and as a value for Optiona), blowing up
   noisily if null encountered.
   2. *Maybe *allow narrow exception to previous for combined filter/map
   and the like as efficient shortcut.
   3. Use Optional for return values where there might not be a result.
   4. Provide non-Optional-returning variants that take a non-null default
   return value to avoid object creation *in some cases*.

That makes things hard for people who like to put nulls in their
collections (e.g., Joe), but things are pretty grim for those people
already: All the really cool collections out there forbid nulls. ;-)


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