Exceptions/Catch an exception thrown in a nested call: Difference between revisions

smalltalk
m (trivial editing of presentation)
(smalltalk)
Line 1,640:
to this
<lang ruby>[1, 2].each {|$bazcount| foo}</lang>
 
=={{header|Smalltalk}}==
 
{{works with|Smalltalk/X}}
functional code, not class based, using blocks as functions, and anonymous exceptions (signals):
<lang Smalltalk>| u0 u1 foo bar baz|
 
u0 := Signal new.
u1 := Signal new.
 
foo := [
2 timesRepeat:[
[ bar value ]
on: u0
do:[ 'u0 cought' printCR ]
]
].
 
bar := [
baz value
].
 
baz := [
|alreadyCalled|
 
[
alreadyCalled isNil ifTrue:[
alreadyCalled := true. u0 raise
] ifFalse:[
u1 raise
]
]
] value.
 
foo value
</lang>
 
=={{header|Tcl}}==
Anonymous user