Anonymous user
Exceptions/Catch an exception thrown in a nested call: Difference between revisions
Exceptions/Catch an exception thrown in a nested call (view source)
Revision as of 03:47, 20 January 2013
, 11 years agosmalltalk
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}}==
|