Did you know ... | Search Documentation: |
![]() | Unification and foreign frames (version 2) |
As documented with PL_unify(), if a unification call fails and
control isn't made immediately to Prolog, any changes made by
unification must be undone. The functions PL_open_foreign_frame(), PL_rewind_foreign_frame(),
and
PL_close_foreign_frame() are encapsulated in the class PlFrame
,
whose destructor calls PL_close_foreign_frame(). Using this, the
example code with PL_unify() can be written:
{ PlFrame frame; ... if ( !t1.unify_term(t2) ) frame.rewind(); ... }
Note that PlTerm::unify_term()
checks for an exception and throws an exception to Prolog; if you with
to handle exceptions, you must call PL_unify_term(t1.C_,t2.C_)
.