Checked exceptions within Block<T>

Gregg Wonderly gregg at
Wed Jan 16 07:23:12 PST 2013

On 1/16/2013 4:09 AM, Remi Forax wrote:
> On 01/16/2013 09:02 AM, Neal Gafter wrote:
>> On Tue, Jan 15, 2013 at 9:41 PM, Brian Goetz <brian.goetz at> wrote:
>>> Dynamic detection is used, for example, to ensure that someone doesn't
>>> [...] call it after the variable to be mutated has gone out of scope.
>> You can't (syntactically) name a variable that is out of scope, so there is
>> no way to mutate it if it is out of scope.
> You can capture it in a lambda and call the lambda that will mutate the
> variable out of the scope.
> Runnable r;
> {
>      int a = 0;
>      r = () -> { a = 1; };
> }
> so it depends if you consider that a still exist or not when you call run.
>>     My point is that variable scope is a lexical concept, and lifetime is a dynamic concept.The variable
>> "comes in and out of scope" every time a lambda in the scope of the
>> variable is executed - and then it is in scope on some threads but not in
>> others.  It is a category error to suggest any dynamic checking would be
>> helpful.
> yes.
> lambdas that capture and mutate a local variable need at least to be
> biased to the current thread and if you consider that accessing to
> mutating a local variable out of it scope is not legal you need another
> check.
Remi, are you saying that the above runnable should run error free, or would it 
generate a RuntimeException of some sort indicating that a is out of "scope" or 
"undefined" when the lambda's references are resolved?

Gregg Wonderly

More information about the lambda-dev mailing list