Effectively final effective?
Mark Thornton
mthornton at optrak.co.uk
Wed Feb 24 15:04:48 PST 2010
Neal Gafter wrote:
> On Wed, Feb 24, 2010 at 2:12 PM, Joshua Bloch <jjb at google.com> wrote:
>
>>> I'd argue that adding the keyword is no more or less difficult than it was
>>> when inner classes were introduced, and that modern IDEs will automatically
>>> prompt you to change the variable to final with a single click if used in an
>>> inner class.
>>>
>> I agree, but most people hate this aspect of anonymous classes, and we can
>> fix it. It's vaguely analogous to what we're doing with the "diamond
>> operator" (<>) for parametrized type instance creation.
>>
>
> It isn't just the visual noise that people find so bothersome. The
> restriction itself is also bothersome, and harder to work around.
>
>
Yet would not many developers be surprised to discover that they
couldn't change an apparently ordinary local variable because it had
been captured by a lambda (or anonymous inner class) some lines previously.
Mark
More information about the lambda-dev
mailing list