• 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

1.4 The class PlTerm
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • A C++ interface to SWI-Prolog
        • A C++ interface to SWI-Prolog (Version 1)
          • The class PlTerm
            • Constructors
            • Casting PlTerm to native C-types
            • Unification
            • Comparison
            • Analysing compound terms
            • Miscellaneous
            • The class PlString
            • The class PlCodeList
            • The class PlCharList
            • The class PlCompound
            • The class PlTail

1.4.3 Unification

int PlTerm::operator =(Type)
The operator = is defined for the Types PlTerm, long, double, char *, wchar_t* and PlAtom. It performs Prolog unification and returns TRUE if successful and FALSE otherwise.

The boolean return-value leads to somewhat unconventional-looking code as normally, assignment returns the value assigned in C. Unification however is fundamentally different to assignment as it can succeed or fail. Here is a common example.

PREDICATE(hostname, 1)
{ char buf[32];

  if ( gethostname(buf, sizeof(buf)) == 0 )
    return A1 = buf;

  return FALSE;
}

ClioPatria (version V3.1.1-48-gf653ce4)