equal
deleted
inserted
replaced
|
1 "{ Encoding: utf8 }" |
|
2 |
1 " |
3 " |
2 This is a Manchester Goodie protected by copyright. |
4 This is a Manchester Goodie protected by copyright. |
3 These conditions are imposed on the whole Goodie, and on any significant |
5 These conditions are imposed on the whole Goodie, and on any significant |
4 part of it which is separately transmitted or stored: |
6 part of it which is separately transmitted or stored: |
5 * You must ensure that every copy includes this notice, and that |
7 * You must ensure that every copy includes this notice, and that |
173 [startSemaphore wait. |
175 [startSemaphore wait. |
174 result := aBlock valueWithArguments: anArray. |
176 result := aBlock valueWithArguments: anArray. |
175 endSemaphore signal] fork |
177 endSemaphore signal] fork |
176 ! ! |
178 ! ! |
177 |
179 |
|
180 !Lazy methodsFor:'printing'! |
|
181 |
|
182 displayOn:aGCOrStream |
|
183 |
|
184 "/ what a kludge - Dolphin and Squeak mean: printOn: a stream; |
|
185 "/ ST/X (and some old ST80's) mean: draw-yourself on a GC. |
|
186 (aGCOrStream isStream) ifFalse:[ |
|
187 ^ self _evaluate_ displayOn:aGCOrStream |
|
188 ]. |
|
189 |
|
190 startSemaphore isNil ifTrue:[ |
|
191 result displayOn:aGCOrStream. |
|
192 aGCOrStream nextPutAll:' (Lazy evaluated)'. |
|
193 ^ self. |
|
194 ]. |
|
195 aGCOrStream nextPutAll:'Lazy (unevaluated)' |
|
196 ! |
|
197 |
|
198 displayString |
|
199 |s| |
|
200 |
|
201 "/ attention: TextStream is not present in ultra-mini standalone apps |
|
202 s := TextStream isNil |
|
203 ifTrue:['' writeStream] |
|
204 ifFalse:[TextStream on:(String new:32)]. |
|
205 self displayOn:s. |
|
206 ^ s contents |
|
207 ! ! |
|
208 |
178 !Lazy methodsFor:'synchronising'! |
209 !Lazy methodsFor:'synchronising'! |
179 |
210 |
180 _evaluate_ |
211 _evaluate_ |
181 "answer the computed value" |
212 "answer the computed value" |
182 |
213 |
196 ! |
227 ! |
197 |
228 |
198 doesNotUnderstand: aMessage |
229 doesNotUnderstand: aMessage |
199 "Any message to a Lazy will end up here." |
230 "Any message to a Lazy will end up here." |
200 |
231 |
201 ^ aMessage sendTo:self _evaluate_ |
232 startSemaphore notNil ifTrue:[ |
|
233 IsDebuggingQuery query ifTrue:[ |
|
234 "enable debugging / inspecting without evaluating" |
|
235 ^ aMessage sendTo:self usingClass:Object. |
|
236 ]. |
|
237 self _evaluate_. |
|
238 ]. |
|
239 |
|
240 ^ aMessage sendTo:result. |
202 ! ! |
241 ! ! |
203 |
242 |
204 !Lazy methodsFor:'testing'! |
243 !Lazy methodsFor:'testing'! |
205 |
244 |
206 isLazyValue |
245 isLazyValue |