Bitten by the lambda parameter name

Zhong Yu zhong.j.yu at
Tue Jul 16 16:37:01 PDT 2013

I don't think people have problems to keep track of scope stacks and
associate a name with its closest definition. Do we have testimonies
of confusions from other languages that allow reusing local names in
lambda parameters?

On Tue, Jul 16, 2013 at 6:25 PM, maurizio cimadamore
<maurizio.cimadamore at> wrote:
> On 16-Jul-13 11:59 PM, Remi Forax wrote:
>> On 07/17/2013 12:40 AM, maurizio cimadamore wrote:
>>> On 16-Jul-13 11:17 PM, Dan Smith wrote:
>>>> >   StringBuilder builder = createText(StringBuilder.class, builder
>>>> -> builder.append("name"));
>>> What is this meant to replace exactly? It's a shorthand for:
>>> StringBuilder builder = new StringBuilder();
>>> builder.append("name");
>>> ?
>>> Maurizio
>> Again, I'm not sure why this is interesting to know exactly what the
>> code does,
>> Anyway, the code of createText allows you to create a mutable object
>> by reflection, to initialize it and when you get the result,
>> you have the guarantee that you can never see the object half
>> initialized.
> I'm asking about the code, because I think that if we are forcing people
> to write code like that there might be a problem other than the scope issue.
> Having two variables so close with the same name is confusing - no
> matter how the language will pan out in the end. YOu seem to imply that
> using the same name is justified by the fact that the two objects are
> really the same - but I'm less sure that many people will be able to
> read your code and immediately grasp as to why the two variables are
> named in the same way. I think a good API should minimize occurrences of
> that for the users sake.
> Maurizio
>> Rémi

More information about the lambda-dev mailing list