Bug in BlockContext ?
Samir Saidani
saidani at info.unicaen.fr
Tue Feb 15 14:24:21 UTC 2005
Hello,
I'm really not sure if this is a bug, or if I don't understand well
the way a BlockContext works in Squeak, so here is the problem :
- create two classes TestBlock1 and TestBlock2
-TestBlock1 has an instance variable nodeCreator which is a Block
creating the class TestBlock2 with another block X and the value for
block X in instance variables.
Try a TestBlock1 new inspect, and then, in the inspection window, try :
(nodeCreator value: Collection) inspect
and in the TestBlock2 inspector, do : block value
this will show :
value :Collection
node :CharacterSet
node :Bag
...
Now in the TestBlock1 inspection window, accept : (nodeCreator value:
Number)
Then return in the same TestBlock2 inspector, and do : block value
and this will show now something different :
value :Number
node :Fraction
...
And I don't understand why, because the expected behavior would be to
have the same block value than the first one. My first guess that the
two instances blocks (from nodeCreator value: Collection and
nodeCreator value: Number) are in fact the same. But when you do a
self oopString on the two block instances, it returns two different
oopString, so they are different. It seems that creating a new
TestBlock2 overwrites the context of the old one. I don't know how to
debug BlockContext to see deeply where is the problem, could someone
give me a method to debug a BlockContext other than Transcript show or
maybe I'm wrong somewhere ? Ideas ?
Thanks !
Samir
'From Squeak3.7 of ''4 September 2004'' [latest update: #5989] on 15
February 2005 at 2:39 pm'!
Object subclass: #TestBlock1
instanceVariableNames: 'nodeCreator'
classVariableNames: ''
poolDictionaries: ''
category: 'Collections-Graphs'!
!TestBlock1 methodsFor: 'as yet unclassified' stamp: 'sam 2/15/2005 01:27'!
initialize
nodeCreator := [:value | TestBlock2
on: value
block: [Transcript show: 'value :', value asString ;cr. ([:class | class subclasses ] value: value)
collect: [:node | Transcript show: 'node :', node asString ;cr.]]].! !
Object subclass: #TestBlock2
instanceVariableNames: 'value block'
classVariableNames: ''
poolDictionaries: ''
category: 'Collections-Graphs'!
block: aBlock
block := aBlock
value: anObject
value := anObject
!TestBlock2 class
on: aValue block: aBlock
^ self new value: aValue;
block: aBlock.
More information about the Squeak-dev
mailing list
|