Idiom for thisContext method with full blocks?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Idiom for thisContext method with full blocks?

Eliot Miranda-2
 
Hi Clément,

    I've written code like this:

        (atEachStepBlock isNil or: [atEachStepBlock method ~~ thisContext method]) ifTrue:
            [...

where the intent is to see if a block is the one created by the current method or not.  This won't work for full blocks.  But at least in my Squeak code and the Pharo7 image as of today there's no accessor for the "home method" yet.  I expect we should be able to write

        (atEachStepBlock isNil or: [atEachStepBlock homeMethod ~~ thisContext homeMethod]) ifTrue:
            [...

where homeMethod is defined as

CompiledCode>>homeMethod
    ^self subclassResponsibility

CompiledMethod>>homeMethod
    ^self

CompiledBlock>>homeMethod
    ^self outerCode homeMethod

Context>>homeMethod
    ^method homeMethod

BlockClosure>>homeMethod
    ^outerContext homeMethod


_,,,^..^,,,_
best, Eliot