|
From: Anthony H. <aj...@co...> - 2004-04-09 13:18:41
|
Ian Piumarta <ian...@in...> wrote: > > > Code in the block and its outer > > methods access these changeable values by sending get and set messages > > to the ValueHolder. > > Is the only reason to send messages to these things the lack of > bytecodes to encode the additional indirections? (Type: > "load/store/pop free var N from enclosing environment at level M".) Right. Although, I only need one indirection. Each closure (environment) is flat and only holds what it needs (its free vars). This means values are copied down for each nested block, but it's better for garbage collection since only values that are needed by the block are copied down and held by the block. Also, I forgot to mention that if an instance variable is captured by a block (is free in the block) then the receiver is captured in the closure environment. Then access to the instance variables is done through instVarAt:(put:) messages. (Actually, instead of "object instVarAt: index put: value" its "value storeIn: object instVar: index" which I added to ProtoObject. This is preferred to maintain the storeTemp pattern which assumes the value is on top of the stack first then you want to store it somewhere.) Finally, analogous to being able to add extra instance variables to CompiledMethod, I would like that same ability for MethodContexts. Cheers, Anthony |