Nice to @Share?
Joshua Bloch
jjb at google.com
Tue Feb 23 11:08:10 PST 2010
Neal,
On Tue, Feb 23, 2010 at 1:39 AM, Neal Gafter <neal at gafter.com> wrote:
The definition of "local variable" in (§4.12.3) is "Local variables
> are declared by local variable declaration statements (§14.4).
> ....<snip>... The local variable effectively ceases to
> exist when the execution of the block or for statement is complete."
>
> The only part of that requiring rewording in the presence of lambdas
> that can access local variables from the enclosing scope is the last
> sentence.
It's only one sentence, but it's a *huge* conceptual change, and not one I
see as justifiable.
>
> A new keyword, while better than what programmers have to do today, is
> still boilerplate.
>
No it isn't. If we decide that lambdas are permitted to reference mutable
local variables (which I believe to be a bad idea), the code should contain
a glaring visual cue that this is being done. Boilerplate is junk that you'd
rather not see but the language requires. This is something I'd desperately
want to see. It's like the volatile keyword, only moreso; it means "dragons
lie here." That said, I'm more than happy with AtomicXxxx or the
single-element array hack.
Josh
More information about the lambda-dev
mailing list