throw. causes execution to resume in thecatcht.
section of an explicit definition that invoked the current code,
returning to immediate execution if there is no such catcht. .
For example:
main=: 3 : 0
try.
sub y
catcht.
select. type_jthrow_
case. 'aaaa' do. 'throw aaaa'
case. 'bbb' do. 'throw bbb'
case. 'cc' do. 'throw cc'
case. do. throw. NB. handled by a higher-level catcht. (if any)
end.
end.
)
sub=: 3 : 0
if. y<0 do. type_jthrow_=: 'aaaa' throw. end.
if. y<4 do. type_jthrow_=: 'bbb' throw. end.
if. y<8 do. type_jthrow_=: 'cc' throw. end.
(":y),' not thrown'
)
main _4
throw aaaa
main 1
throw bbb
main 5
throw cc
main 88
88 not thrown
A throw. can communicate information back to
a catcht. through the use of a global name in a locale,
as illustrated in the examples above.