#QUALITY by stefan
class: LazyValue
changed:
#displayOn:
#doesNotUnderstand:
category of:
#_evaluate_
#doesNotUnderstand:
support for inspecting
--- a/LazyValue.st Wed Jul 27 17:16:06 2016 +0200
+++ b/LazyValue.st Wed Jul 27 17:16:19 2016 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 2002 by eXept Software AG
All Rights Reserved
@@ -402,31 +404,6 @@
^ self new block:aBlock
! !
-!LazyValue methodsFor:'error handling'!
-
-doesNotUnderstand:aMessage
- block notNil ifTrue:[
- self _evaluate_
- ].
- ^ aMessage sendTo:result
-! !
-
-!LazyValue methodsFor:'evaluation'!
-
-_evaluate_
- block notNil ifTrue:[
- lock wait. "ensure that block is only executed once"
- block notNil ifTrue:[
- result := block value.
- block := nil.
-
- lock signalForAll.
- lock := nil.
- ].
- ].
- ^ result
-! !
-
!LazyValue methodsFor:'printing'!
displayOn:aGCOrStream
@@ -442,7 +419,8 @@
aGCOrStream nextPutAll:' (lazyValue evaluated)'.
^ self.
].
- aGCOrStream nextPutAll:'LazyValue (unevaluated)'
+ aGCOrStream nextPutAll:'LazyValue (unevaluated) block: '.
+ block displayOn:aGCOrStream.
!
displayString
@@ -469,6 +447,33 @@
^ self _evaluate_ class
! !
+!LazyValue methodsFor:'synchronising'!
+
+_evaluate_
+ block notNil ifTrue:[
+ lock wait. "ensure that block is only executed once"
+ block notNil ifTrue:[
+ result := block value.
+ block := nil.
+
+ lock signalForAll.
+ lock := nil.
+ ].
+ ].
+ ^ result
+!
+
+doesNotUnderstand:aMessage
+ block notNil ifTrue:[
+ IsDebuggingQuery query ifTrue:[
+ "enable debugging / inspecting without evaluating"
+ ^ aMessage sendTo:self usingClass:Object.
+ ].
+ self _evaluate_.
+ ].
+ ^ aMessage sendTo:result
+! !
+
!LazyValue methodsFor:'testing'!
isBehavior