Skip to content
Prev Previous commit
Next Next commit
cherry-pick of fixes to GRDynamicVariable (commit e5eee3b)
  • Loading branch information
Johan Brichau committed Sep 9, 2017
commit 919b273be54ea07430be16263a888b4e512cf6b3
Original file line number Diff line number Diff line change
@@ -1,11 +1,18 @@
accessing
use: anObject during: aBlock
| p oldValue result |
"Proper implementation instead of use 'super value:during:' because that one does not return value, perhaps this should be fixed in DynamicVariable?"
| p hasOldValue oldValue result |
"Implementation cannot send a supercall to value:during: because:
- this method needs to return the value
- the defaultValue may not be invoked here to support throwing errors as defaultValue
- nil may not remain installed as the default value once the block has finished running"
p := Processor activeProcess.
hasOldValue := p environment includesKey: self.
oldValue := p environmentAt: self.
[
p environmentAt: self put: anObject.
result := aBlock value ]
ensure: [ p environmentAt: self put: oldValue ].
ensure: [
hasOldValue
ifFalse: [ p environment removeKey: self ]
ifTrue: [ p environmentAt: self put: oldValue ] ].
^ result
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
"class" : {
"default" : "JohanBrichau 07/23/2017 09:48",
"defaultValue" : "JohanBrichau 07/23/2017 09:47",
"use:during:" : "JohanBrichau 07/23/2017 07:39" },
"use:during:" : "JB 09/08/2017 00:34" },
"instance" : {
} }
Loading