Please help with valueWithArguments: mystery
Ned Konz
ned at bike-nomad.com
Tue Feb 13 23:24:44 UTC 2001
I have a Morph class that uses a pluggable BlockContext in its step method.
I set this BlockContext like this:
targetBlock _ aBlock fixTemps.
aBlock may be something like:
[ :a :b | b center ]
In the step method, I'm doing this:
targetBlock valueWithArguments: inputs
where inputs is (in this case) a 2-element WeakArray in an instance variable.
Unfortunately, I get errors when I execute this code that say that the
BlockContext is already being executed! (there are two of these Morphs in
existence at this time, so I get two debuggers popping up).
If I change the code in my step method to:
targetBlock value: inputs first value: inputs second
everything works OK.
I have also tried
targetBlock valueWithArguments: inputs copy
to no avail.
I have also tried setting the targetBlock without using fixTemps.
Any suggestions? This is with the Unix 3.0 VM, under Linux, and a 3.1 image.
I've attached a minimal demo class that shows this problem. There are two
examples on the class side.
--
Ned Konz
currently: Stanwood, WA
email: ned at bike-nomad.com
homepage: http://bike-nomad.com
-------------- next part --------------
'From Squeak3.1alpha of 7 February 2001 [latest update: #3583] on 13 February 2001 at 3:22:51 pm'!
"Change Set: ValueWithArgsBug-nk
Date: 13 February 2001
Author: Ned Konz
This demonstrates a problem with valueWithArguments:
this shows the problem:
VWAMorph example1
this works OK:
VWAMorph example2
"!
Morph subclass: #VWAMorph
instanceVariableNames: 'targetBlock inputs useValueWithArguments '
classVariableNames: ''
poolDictionaries: ''
category: 'NK-Bugs'!
!VWAMorph commentStamp: 'nk 2/13/2001 15:21' prior: 0!
This demonstrates a problem with valueWithArguments:
this shows the problem:
VWAMorph example1
this works OK:
VWAMorph example2!
!VWAMorph methodsFor: 'initialization' stamp: 'nk 2/13/2001 15:18'!
initializeOn: other
targetBlock _ [ :a :b | b center ].
inputs _ WeakArray with: self with: other.
useValueWithArguments _ false.! !
!VWAMorph methodsFor: 'initialization' stamp: 'nk 2/13/2001 15:19'!
useValueWithArguments: aBoolean
useValueWithArguments _ aBoolean! !
!VWAMorph methodsFor: 'stepping and presenter' stamp: 'nk 2/13/2001 15:19'!
step
self center: (useValueWithArguments
ifTrue: [ targetBlock valueWithArguments: inputs ]
ifFalse: [ targetBlock value: inputs first value: inputs second ])! !
!VWAMorph class methodsFor: 'as yet unclassified' stamp: 'nk 2/13/2001 15:20'!
example1
"This doesn't work"
"VWAMorph example1"
| r v |
r _ RectangleMorph new extent: 70 at 70; center: 100 at 100; openInWorld.
v _ (VWAMorph new) initializeOn: r; useValueWithArguments: true.
v openInWorld.! !
!VWAMorph class methodsFor: 'as yet unclassified' stamp: 'nk 2/13/2001 15:20'!
example2
"This does work"
"VWAMorph example2"
| r v |
r _ RectangleMorph new extent: 70 at 70; center: 100 at 100; openInWorld.
v _ (VWAMorph new) initializeOn: r; useValueWithArguments: false.
v openInWorld.! !
VWAMorph removeSelector: #initialize!
!VWAMorph reorganize!
('initialization' initializeOn: useValueWithArguments:)
('stepping and presenter' step)
!
More information about the Squeak-dev
mailing list
|