Skip to content

Instantly share code, notes, and snippets.

Created August 2, 2011 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/1120594 to your computer and use it in GitHub Desktop.
Save anonymous/1120594 to your computer and use it in GitHub Desktop.
pmichaud@kiwi:~/nom$ cat y.pir
.sub 'main' :main
$P0 = new ['ExceptionHandler']
set_label $P0, handler
push_eh $P0
'a'()
'a'()
exit 0
handler:
.local pmc exception
.get_results (exception)
say 'caught exception'
pop_eh
$P0 = getattribute exception, 'resume'
say 'resuming after exception'
$P0()
.end
.sub 'a'
say "In subroutine 'a'"
die "first exception"
say "resumed 'a' after first exception"
die "second exception"
say "resumed 'a' after second exception"
say "leaving 'a'"
.end
pmichaud@kiwi:~/nom$ install/bin/parrot y.pir
In subroutine 'a'
caught exception
resuming after exception
resumed 'a' after first exception
second exception
current instr.: 'a' pc 55 (y.pir:23)
called from Sub 'main' pc 44 (y.pir:16)
pmichaud@kiwi:~/nom$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment