--- a/Block.st Sat Jul 31 16:34:56 1999 +0200
+++ b/Block.st Sat Jul 31 16:36:41 1999 +0200
@@ -1510,22 +1510,7 @@
aBlock is also evaluated in case of abnormal termination.
(the same as #valueNowOrOnUnwindDo:)"
- |v|
-
-"/ #ensure could be implemented as:
-"/
-"/ [
-"/ v := self value.
-"/ ] valueNowOrOnUnwindDo:aBlock.
-"/ ^ v
-"/
-"/ however, we save one block creation, by doing it as:
-"/
- thisContext markForUnwind.
- v := self value. "the real logic is in Context>>unwind"
- thisContext unmarkForUnwind.
- aBlock value.
- ^ v
+ ^ self valueNowOrOnUnwindDo:aBlock
"
[
@@ -1538,6 +1523,7 @@
].
] fork.
"
+
"
[
[
@@ -1551,6 +1537,19 @@
!
+unwindHandlerInContext:aContext
+ "given a context which has been marked for unwind,
+ retrieve the handler block.
+ This avoids hardwiring access to the first argument in
+ #unwind methods (and theoretically allows for other unwinding
+ methods to be added)"
+
+ "/ for now, only #valueNowOrOnUnwindDo:
+ "/ or #valueOnUnwindDo:
+
+ ^ aContext argAt:1
+!
+
valueNowOrOnUnwindDo:aBlock
"evaluate the receiver - after that, or when some method sent within unwinds (i.e. does
a long return), evaluate the argument, aBlock.
@@ -1604,6 +1603,6 @@
!Block class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.87 1999-07-31 13:54:59 cg Exp $'
+ ^ '$Header: /cvs/stx/stx/libbasic/Block.st,v 1.88 1999-07-31 14:36:41 cg Exp $'
! !
Block initialize!