Nulls
Bob Lee
crazybob at crazybob.org
Wed Sep 26 18:09:25 PDT 2012
3.
Bob
On Wed, Sep 26, 2012 at 5:13 PM, Sam Pullara <sam at sampullara.com> wrote:
> I choose 3. Easy to filter them out if you like 2 or fail if you like
> 1. 4 is just weird to me.
>
> Sam
>
> On Wed, Sep 26, 2012 at 1:00 PM, Brian Goetz <brian.goetz at oracle.com>
> wrote:
> > Trying again to categorize the choices and identify pros/cons...
> >
> > Seems like there are four buckets here:
> >
> > 1. Ban nulls. This means that feeding nulls into a Stream MUST produce
> an
> > NPE.
> >
> > 2. Ignore nulls.
> >
> > 3. Tolerate nulls. Streams API takes no position on nulls, but may well
> > pass elements to less tolerant destinations (e.g., user-provided lambdas,
> > user-provided collections, Optional constructor.) Nulls may cause NPEs
> in
> > these cases.
> >
> > 4. Embrace nulls. Ensure that every operation can deal with nulls in a
> > well-defined manner. (This entails, for example, either dropping the
> > Optional-bearing methods or making present Optional deal with null.)
> >
> >
> > I think its safe to say that for each of these, there is some subset of
> us
> > who finds it undesirable.
> >
> > Doug proposed (2) and (4). I proposed (3). Nearly everyone has some
> > sympathy for (1) but no one really wants to be that intolerant.
> >
> >
> > Attempted summary of pros/cons:
> >
> > 1 PRO: Predictable, simple
> > 1 CON: Might be overly harsh, interferes with when user might actually
> want
> > to see nulls and can deal accordingly
> >
> > 2 PRO: Simple
> > 2 CON: size() lies, interferes with optimizations, interferes with when
> user
> > might actually want to see nulls and can deal accordingly
> >
> > 3 PRO: Minimizes distortion on API, implementation in the null-free case
> > 3 CON: more complex reasoning about what might happen, op behavior may
> > change subtly over time as implementation changes
> >
> > 4 PRO: Predictable
> > 4 CON: sacrifices functionality/safety for sake of a corner case
> >
> >
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.openjdk.java.net/pipermail/lambda-libs-spec-experts/attachments/20120926/066edbb6/attachment.html
More information about the lambda-libs-spec-experts
mailing list