Advertisement
logicmoo

Catch as an exception handler binder

Jan 18th, 2016
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Prolog 0.33 KB | None | 0 0
  1. :- nb_setval('$my_handler',[h(Ex,$throw(Ex)])).
  2.  
  3.  
  4. throw(E):-  b_getval('$ex_handler',List),member(h(E,H),List), H , $next_instruction.
  5.  
  6. catch(G,E,H):-
  7.          b_getval('$ex_handler',Previous),
  8.          b_setval('$ex_handler',[h(E,H)|Previous]),
  9.          G,
  10.      label_next:
  11.           nb_setval('$ex_handler',Previous).
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement