Bitten by the lambda parameter name
john.r.rose at oracle.com
Fri Jul 19 14:55:39 PDT 2013
On Jul 18, 2013, at 5:40 PM, Zhong Yu <zhong.j.yu at gmail.com> wrote:
> Hi John, what name do you propose for the lambda parameter?
I don't have a solid preference or proposal. Most of the alternatives you mention are workable in one situation or another. One choice doesn't fit all situations.
This thread does show one reason why functional languages tend to have a syntax for "no-name" parameters. (Cue slide on K combinators.)
The substantial issue here, IMO, is API support for what is sometimes called "auto-vivification" of nested data structures, as in this broken code:
Map<J, Map<K, List<V>>> bimap = ...;
bimap.get(j).get(k).add(v); // BAD NPE
Using "IfAbsent" methods, a fix might look something like:
bimap.computeIfAbsent(j, TreeMap<>::new).computeIfAbsent(k, ArrayList<>::new).add(v);
...except for the extra key arguments, which seem spurious in this use case.
More information about the lambda-dev