Block Equality (and startpc)

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

Block Equality (and startpc)

Sean P. DeNigris
Administrator
Currently,
BlockClosure >> #= aClosure
        self == aClosure ifTrue: [^true].
        aClosure class = self class ifFalse: [^false].
        (self method == aClosure method and: [startpc = aClosure startpc and: [self
isClean]]) "<--- this line"
                ifTrue: [^true].
        ^outerContext = aClosure outerContext and: [startpc = aClosure startpc]

I wonder about `startpc = aClosure startpc` the first time it appears (in
the comment-marked line). With it, in a workspace, the following is false:
`[1] = [1]`, but removing that test makes it true. I'm not an expert on
blocks, but doesn't `#isClean` preclude the need/desire for a startpc check
in that statement?



-----
Cheers,
Sean
--
Sent from: http://forum.world.st/Squeak-Dev-f45488.html

Cheers,
Sean
Reply | Threaded
Open this post in threaded view
|

Re: Block Equality (and startpc)

Levente Uzonyi
On Fri, 4 Oct 2019, Sean P. DeNigris wrote:

> Currently,
> BlockClosure >> #= aClosure
> self == aClosure ifTrue: [^true].
> aClosure class = self class ifFalse: [^false].
> (self method == aClosure method and: [startpc = aClosure startpc and: [self
> isClean]]) "<--- this line"
> ifTrue: [^true].
> ^outerContext = aClosure outerContext and: [startpc = aClosure startpc]
>
> I wonder about `startpc = aClosure startpc` the first time it appears (in
> the comment-marked line). With it, in a workspace, the following is false:
> `[1] = [1]`, but removing that test makes it true. I'm not an expert on
> blocks, but doesn't `#isClean` preclude the need/desire for a startpc check
> in that statement?

But if you remove the comparison of startpcs, `[1] = [2]` will yield true
as well. So, no, #isClean alone is not enough.
They way I see it, the startpc comparison lets us not to compare the
contents of the block, but limiting #= to return true iff two activations
of the same block are compared.

Levente

>
>
>
> -----
> Cheers,
> Sean
> --
> Sent from: http://forum.world.st/Squeak-Dev-f45488.html