> > Blocks > ====== > Status: All tests green when compiling with ConstantBlockClosure (but the > option is not yet enabled by default) > Work continues to reducing the use of #home, this week by using #homeMethod > instead of "home method” >
And there are more in need of review, for example: 11965-Implement-ContextactiveHome-without-using-home #12063 https://github.com/pharo-project/pharo/pull/12063 #activeHome returns the #home if it is currently on the stack, the debugger uses that to check if a “save and proceed” is possible when editing code in a Block. It is implemented to search up the sender chain until it finds the #home: activeHome | methodReturnContext | self isBlockContext ifFalse: [^self]. self sender ifNil: [^nil]. methodReturnContext := self methodReturnContext. ^self sender findContextSuchThat: [:ctxt | ctxt = methodReturnContext] But it can be rewritten to do the same, but checking for the #homeMethod: activeHome | homeMethod | self isBlockContext ifFalse: [^self]. homeMethod := self homeMethod. ^self findMethodContextSuchThat: [:ctxt | ctxt method == homeMethod] With #homeMethod being implemented to delegate to the bock: Context>>homeMethod "Answer the method in which the receiver was defined, i.e. the context from which an ^-return ] should return from. Note: implemented to not need #home" ^ closureOrNil ifNil: [ self method ] ifNotNil: [ :closure | closure homeMethod ] Where, if no #outerContext is available, it asks the CompiledBlock: BlockClosure>>homeMethod "return the home method. If no #home is available due to no outerContext, use the compiledBlock" ^ (self home ifNotNil: [ :homeContext | homeContext ] ifNil: [ self compiledBlock ]) method Which uses the static #outerCode chain (CompiledBlocks encode have a back-pointer to the enclosing block or method), with #method following #outerCode until it reaches a CompiledMethod: CompiledBlock>>method "answer the compiled method that I am installed in, or nil if none.” ^self outerCode method