14th October Lambdas Hackday
Remi Forax
forax at univ-mlv.fr
Sun Oct 21 11:31:13 PDT 2012
On 10/21/2012 03:56 PM, Richard Warburton wrote:
> Lambdas Hackday
>
> Last Sunday (14th October) the London Java Community ran another
> hackday on the lambdas binary builds. Brian Goetz was there, so i
> imagine that the majority of the feedback has already been discussed
> somewhat. I still think its useful to post a brief summary of what
> people found confusing to the public lists so people outside the EG
> can see what’s going on.
>
> 1. What is the idiomatic way of expressing a generator function? So
> far no one has answered this one for me, and I can't think of a good
> answer myself!
Until we get coroutines (there is a patch in mlvm workspace for that)
the answer seems to be that there is no good way to express a generator
function.
> 2. The design of flatMap confused a lot of people. They didn’t seem
> to understand the callback was a block. It was much easier to explain
> the intended purpose via an example than anything else. It might
> simply be the case that ‘Block’ is a bad name for result callback
> handler, though I appreciate that people wish to avoid interface
> proliferation.
> 3. People didn’t understand why Stream.fold() takes both a Combiner
> and a BinaryOp, rather than just a combiner.
> 4. Any code that relies on getClass() is hard to transform from an
> anonymous inner class into a lambda. This is because getClass() on a
> lambda returns the class that it was defined within, rather than the
> class of the anonymous inner class. It makes sense from the
> perspective of lambdas being like blocks - but it will break things
> down the line so there should probably be at least a “Beware!” type
> warning.
The issue is more general that just getClass().
'this' in an anonymous class refers to the anonymous class instance
and 'this' in a lambda refers to the enclosing class.
So beware when you retrofit an anonymous class to a lambda.
For newbie that doesn't know what an anonymous class is but are exposed
to the inner class syntax, e.g. most of my students before my course,
they often think that 'this' in an anonymous class refers to the
enclosing class,
and no the anonymous hidden class so if we have to put a warning
somewhere and I don't think so,
it should be in inner classes, not in lambda.
> 5. The base argument of Stream.reduce() needs to be the identity value
> of the combiner function if you're to get the correct answer when
> running in parallel. This wasn't at all obvious to developers, and
> seems like a real gotcha for people when parallel collections are
> meant to be a simple method of obtaining parallelism.
>
> I’ll omit the bug reports (since Maurizio has already fixed them) but
> link to a full feedback pastebin that people used below:
>
> https://docs.google.com/document/d/1MranKyn-bY5uhwCEYsdKkTWnvzrUVkoZEAIehRbu-ck/edit#heading=h.vh350hbhq21c
>
> Thanks to Brian for coming over and The JAX London Conference for
> space to run the hackday in.
>
> regards,
>
> Richard
>
regards,
Rémi
More information about the lambda-dev
mailing list