June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -1,30 +1,25 @@
|
|||
| u0 u1 foo bar baz|
|
||||
Exception subclass: #U0.
|
||||
Exception subclass: #U1.
|
||||
|
||||
u0 := Signal new.
|
||||
u1 := Signal new.
|
||||
Object subclass: Foo [
|
||||
|
||||
foo := [
|
||||
2 timesRepeat:[
|
||||
[ bar value ]
|
||||
on: u0
|
||||
do:[ 'u0 cought' printCR ]
|
||||
]
|
||||
].
|
||||
bazCount := 0.
|
||||
|
||||
bar := [
|
||||
baz value
|
||||
].
|
||||
foo
|
||||
[2 timesRepeat:
|
||||
[ "==>" [self bar] "<=="
|
||||
on: U0
|
||||
do:
|
||||
[:sig |
|
||||
'Call to bar was aborted by exception U0' printNl.
|
||||
sig return]]]
|
||||
|
||||
baz := [
|
||||
|alreadyCalled|
|
||||
bar
|
||||
[self baz]
|
||||
|
||||
[
|
||||
alreadyCalled isNil ifTrue:[
|
||||
alreadyCalled := true. u0 raise
|
||||
] ifFalse:[
|
||||
u1 raise
|
||||
]
|
||||
]
|
||||
] value.
|
||||
|
||||
foo value
|
||||
baz
|
||||
[bazCount := bazCount + 1.
|
||||
bazCount = 1 ifTrue: [U0 new signal].
|
||||
bazCount = 2 ifTrue: [U1 new signal].
|
||||
"Thirds time's a charm..."]
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,43 +1,11 @@
|
|||
Exception
|
||||
subclass: #U0
|
||||
instanceVariableNames:''
|
||||
classVariableNames:''
|
||||
poolDictionaries:''
|
||||
category:'example'.
|
||||
|
||||
Exception
|
||||
subclass: #U1
|
||||
instanceVariableNames:''
|
||||
classVariableNames:''
|
||||
poolDictionaries:''
|
||||
category:'example'.
|
||||
|
||||
Object
|
||||
subclass: #CatchMeIfYouCan
|
||||
instanceVariableNames:'bazAlreadyCalled'
|
||||
classVariableNames:''
|
||||
poolDictionaries:''
|
||||
category:'example'.
|
||||
|
||||
" CatchMeIfYouCan methods "
|
||||
|
||||
foo
|
||||
2 timesRepeat:[
|
||||
[ self bar ]
|
||||
on: U0
|
||||
do:[ 'U0 cought' printCR ]
|
||||
]
|
||||
|
||||
bar
|
||||
self baz
|
||||
|
||||
|
||||
baz
|
||||
bazAlreadyCalled isNil ifTrue:[
|
||||
bazAlreadyCalled := true.
|
||||
U0 raise
|
||||
] ifFalse:[
|
||||
U1 raise
|
||||
]
|
||||
|
||||
CatchMeIfYouCan new foo
|
||||
st> Foo new foo
|
||||
'Call to bar was aborted by exception U0'
|
||||
Object: Foo new "<-0x4c9a7960>" error: An exception has occurred
|
||||
U1(Exception)>>signal (ExcHandling.st:254)
|
||||
Foo>>baz (catch_exception.st:32)
|
||||
Foo>>bar (catch_exception.st:27)
|
||||
optimized [] in Foo>>foo (catch_exception.st:19)
|
||||
BlockClosure>>on:do: (BlkClosure.st:193)
|
||||
Foo>>foo (catch_exception.st:20)
|
||||
UndefinedObject>>executeStatements (a String:1)
|
||||
nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue