2.15 The PREDICATE and PREDICATE_NONDET macros (version 2)
AllApplicationManualNameSummaryHelp

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

2.15.1 Variations of the PREDICATE macro (version 2)

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

PREDICATE0(name)
This is the same as PREDICATE(name, 0). It avoids a compiler warning about 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)
    { A2 = (wchar_t*)A1;
    }
    
PREDICATE_NONDET(name, arity)
Define a non-deterministic Prolog predicate in C++. See also section 2.15.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 2.15.2.