X Tutup
Skip to content

Commit 919b273

Browse files
author
Johan Brichau
committed
cherry-pick of fixes to GRDynamicVariable (commit e5eee3b)
1 parent 3f844f3 commit 919b273

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,18 @@
11
accessing
22
use: anObject during: aBlock
3-
| p oldValue result |
4-
"Proper implementation instead of use 'super value:during:' because that one does not return value, perhaps this should be fixed in DynamicVariable?"
3+
| p hasOldValue oldValue result |
4+
"Implementation cannot send a supercall to value:during: because:
5+
- this method needs to return the value
6+
- the defaultValue may not be invoked here to support throwing errors as defaultValue
7+
- nil may not remain installed as the default value once the block has finished running"
58
p := Processor activeProcess.
9+
hasOldValue := p environment includesKey: self.
610
oldValue := p environmentAt: self.
711
[
812
p environmentAt: self put: anObject.
913
result := aBlock value ]
10-
ensure: [ p environmentAt: self put: oldValue ].
14+
ensure: [
15+
hasOldValue
16+
ifFalse: [ p environment removeKey: self ]
17+
ifTrue: [ p environmentAt: self put: oldValue ] ].
1118
^ result

repository/Grease-GemStone-Core.package/GRDynamicVariable.class/methodProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@
22
"class" : {
33
"default" : "JohanBrichau 07/23/2017 09:48",
44
"defaultValue" : "JohanBrichau 07/23/2017 09:47",
5-
"use:during:" : "JohanBrichau 07/23/2017 07:39" },
5+
"use:during:" : "JB 09/08/2017 00:34" },
66
"instance" : {
77
} }

0 commit comments

Comments
 (0)
X Tutup