LazyValue.st
changeset 1071 0f74a3bb42a7
parent 1042 b7160172e039
child 1072 7e2d41c7b33a
--- a/LazyValue.st	Tue Jul 23 21:43:47 2002 +0200
+++ b/LazyValue.st	Thu Jul 25 16:38:51 2002 +0200
@@ -53,6 +53,14 @@
 
 examples
 "
+                                                        [exBegin]
+    |x|
+
+    x := LazyValue block:[ Transcript flash. 1234 ].
+    Delay waitForSeconds:4.
+    Transcript showCR:x printString
+                                                        [exEnd]
+
   listFrom:n - an infinite list of integers starting with n
                                                         [exBegin]
     |gen infiniteList|
@@ -284,7 +292,7 @@
         AccessLock critical:[
             |b|
 
-            (b := block notNil) ifTrue:[
+            (b := block) notNil ifTrue:[
                 block := nil.
                 result := b value.
             ].
@@ -295,6 +303,13 @@
 
 !LazyValue methodsFor:'printing'!
 
+displayString
+    block isNil ifTrue:[
+        ^ 'LazyValue (unevaluated)'
+    ].
+    ^ 'LazyValue (evaluated)'
+!
+
 printOn:aStream
     aStream nextPutAll:'(lazy)'
 ! !
@@ -324,6 +339,6 @@
 !LazyValue class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libbasic2/LazyValue.st,v 1.1 2002-06-07 15:23:46 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libbasic2/LazyValue.st,v 1.2 2002-07-25 14:38:51 cg Exp $'
 ! !
 LazyValue initialize!