- Documentation
- Reference manual
- Packages
- A C++ interface to SWI-Prolog
- A C++ interface to SWI-Prolog (Version 2)
- Summary of changes between Versions 1 and 2
- Introduction (version 2)
- The life of a PREDICATE (version 2)
- Overview (version 2)
- Examples (version 2)
- Rational for changes from version 1 (version 2)
- Porting from version 1 to version 2
- The class PlFail (version 2)
- The class PlTerm (version 2)
- The class PlTermv (version 2)
- The class PlAtom - Supporting Prolog constants (version 2)
- Unification and foreign frames (version 2)
- The class PlRegister (version 2)
- The class PlQuery (version 2)
- The PREDICATE and PREDICATE_NONDET macros (version 2)
- Exceptions (version 2)
- Embedded applications (version 2)
- Considerations (version 2)
- Conclusions (version 2)
- A C++ interface to SWI-Prolog (Version 2)
- A C++ interface to SWI-Prolog
2.12 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_)
.