forax at univ-mlv.fr
Sun Sep 23 06:34:37 PDT 2012
On 09/23/2012 03:12 PM, Doug Lea wrote:
> On 09/23/12 08:38, Tim Peierls wrote:
>> On Sun, Sep 23, 2012 at 8:07 AM, Doug Lea <dl at cs.oswego.edu
>> <mailto:dl at cs.oswego.edu>> wrote:
>> The main downside is that findAny is forced to lie (reporting
>> absent) if a
>> null item matches predicate.
>> Doesn't bother me.
> It encounters the same antipattern seen when you
> need to establish that a Map key has no mapping:
> if (map.get(k) == null) // don't know if there is a mapping
> if (!map.containsKey(k)) // so recheck
> Which might not seem so terrible in particular cases where
> you are prepared to cope with mappings to null. But the
> issues make it impossible to write some generic
> Map utilities because the need to recheck forces non-atomicity.
yes, for Map, we need a getEntry() but introducing it now as a default
method will have the same problem that the default implementation is not
> For findAny etc, the issue is even harder:
> if (!...findAny(...).isPresent())
> // somehow recheck?
> And the need for recheck is even less obvious.
More information about the lambda-libs-spec-observers