map and null values
Doug Lea
dl at cs.oswego.edu
Fri Jan 4 03:35:10 PST 2013
On 01/03/13 22:09, Jed Wesley-Smith wrote:
> If we can agree that nulls should essentially be deprecated as a legal
> value or key then we avoid all the complicated gymnastics this thread
> shows are necessary to support them.
>
The impact of doing this for all Maps for JDK8 (or ever)
would be too disruptive. Which is too bad, because the nullness
issue is the main (although not the only) impediment to
creating a Stream-like analog for Maps. In the mean time,
JDK8 ConcurrentHashMap will support its own
non-streamy bulk operation framework. Which is powerful
enough to fully support all hadoop-style processing,
but for the sake of not eliminating future options,
has a very different (but very conventional) look-and-feel.
See javadocs at:
http://gee.cs.oswego.edu/dl/jsr166/dist/docs/java/util/concurrent/ConcurrentHashMap.html
(I think this will be integrated soon into lambda.)
One of the byproducts of the consistent interpretation
of null as "nothing there" is that CHM bulk methods allow
you to write complex map functions (for map-reduce-like
operations) that can both select and transform arguments,
returning null to mean unselected. This may seem weird until
you get used to it, but then seems indispensable.
-Doug
More information about the lambda-dev
mailing list