Definite Assignment rules for lambda expressions...
Neal Gafter
neal at gafter.com
Thu Jan 21 17:05:42 PST 2010
Alex Buckley pointed out to me that the CfJ 0.6a rules for definite
assignment are a bit informal:
The body of a closure literal may not assign to a final variable declared
outside the closure literal.
A closure literal does not affect the DA/DU status of any free variables it
names.
A free variable referenced inside a closure literal receives its initial DA
state from the DA state of the variable at the point where the closure
literal appears.
So I've updated it to the slightly more formal JLS-speak
A variable V is (un)assigned after a lambda expression iff V is (un)assigned
before the lambda expression
A variable V used in a lambda expression's body but declared outside the
lambda is
- definitely assigned before the lambda expression's body iff V is
definitely assigned before the lambda expression; and
- not definitely unassigned before the lambda expression's body.
The last bullet recognizes that a (blank final) variable might be assigned
somewhere else in the program before the lambda is invoked.
Cheers,
Neal
More information about the lambda-dev
mailing list