I checked in support for closure access to lexical scope including both an implicit this and local variables.
If the closure needs access to "this" in an instance method, then a "this$" field is auto-generated in the closure's implementation and passed to the constructor. This work occurs in the ResolveVars compiler step (code in ClosureExpr). Do you guys think we should allow use of the "this" keyword inside the closure itself (I don't have that today)?
If the closure needs access to local variables, then a "cvars" class is defined with a field for each local variable used by the closure. Then all access to these local variables are remapped to the cvars fields in both the method body and in the closure. Within the closure we store the cvars as a field and pass it to the constructor. This work occurs in the ClosureVars compiler step.
andyMon 13 Mar 2006
If you already have that info, then yeah I suppose - not sure the use case though.
brian Mon 13 Mar 2006
I checked in support for closure access to lexical scope including both an implicit this and local variables.
If the closure needs access to "this" in an instance method, then a "this$" field is auto-generated in the closure's implementation and passed to the constructor. This work occurs in the ResolveVars compiler step (code in ClosureExpr). Do you guys think we should allow use of the "this" keyword inside the closure itself (I don't have that today)?
If the closure needs access to local variables, then a "cvars" class is defined with a field for each local variable used by the closure. Then all access to these local variables are remapped to the cvars fields in both the method body and in the closure. Within the closure we store the cvars as a field and pass it to the constructor. This work occurs in the ClosureVars compiler step.
andy Mon 13 Mar 2006
If you already have that info, then yeah I suppose - not sure the use case though.