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

1.14 The PREDICATE and PREDICATE_NONDET macros
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • A C++ interface to SWI-Prolog
        • A C++ interface to SWI-Prolog
          • The PREDICATE and PREDICATE_NONDET macros
            • Variations of the PREDICATE macro
            • Non-deterministic predicates
            • Controlling the Prolog destination module

1.14.1 Variations of the PREDICATE macro

The PREDICATE() macros have a number of variations that deal with special cases.

PREDICATE(name, arity)
Create a predicate with an automatically generated internal name, and register it with Prolog. The various term arguments are accessible as A1, A2, etc.
PREDICATE0(name)
This is the same as PREDICATE(name, 0). It avoids a compiler warning that PL_av is not used.
NAMED_PREDICATE(plname, cname, arity)
This version can be used to create predicates whose name is not a valid C++ identifier. Here is a ---hypothetical--- example, which unifies the second argument with a stringified version of the first. The cname is used to create a name for the functions. The concrete name does not matter, but must be unique. Typically it is a descriptive name using the limitations imposed by C++ indentifiers.
    NAMED_PREDICATE("#", hash, 2)
    { return A2.unify_string(A1.as_string());
    }
    
PREDICATE_NONDET(name, arity)
Define a non-deterministic Prolog predicate in C++. See also section 1.14.2.
NAMED_PREDICATE_NONDET(plname, cname, arity)
Define a non-deterministic Prolog predicate in C++, whose name is not a valid C++ identifier. See also section 1.14.2.

ClioPatria (version V3.1.1-51-ga0b30a5)