• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

2 A C++ interface to SWI-Prolog (Version 2)
All Application Manual Name SummaryHelp

  • 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
          • Sample code (version 2)
          • Introduction (version 2)
          • The life of a PREDICATE (version 2)
          • Overview (version 2)
          • Examples (version 2)
          • Rationale 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)
          • Classes for the recorded database: PlRecord and PlRecordExternalCopy
          • 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)

2.14 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_).

ClioPatria (version V3.1.1-48-gf653ce4)