• 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

12.4.22 Registering Foreign Predicates
All Application Manual Name SummaryHelp

  • Documentation
    • Reference manual
      • Foreign Language Interface
        • The Foreign Include File
          • Registering Foreign Predicates
            • PL_register_foreign_in_module()
            • PL_register_foreign()
            • PL_register_extensions_in_module()
            • PL_register_extensions()
    • Packages
Availability:C-language interface function
void PL_register_extensions_in_module(const char *module, PL_extension *e)
Register a series of predicates from an array of definitions of the type PL_extension in the given module. If module is NULL, the predicate is created in the module of the calling context, or if no context is present in the module user. The PL_extension type is defined as
typedef struct PL_extension
{ char          *predicate_name; /* Name of the predicate */
  short         arity;           /* Arity of the predicate */
  pl_function_t function;        /* Implementing functions */
  short         flags;           /* Or of PL_FA_... */
} PL_extension;

For details, see PL_register_foreign_in_module(). Here is an example of its usage:

static PL_extension predicates[] = {
{ "foo",        1,      pl_foo, 0 },
{ "bar",        2,      pl_bar, PL_FA_NONDETERMINISTIC },
{ NULL,         0,      NULL,   0 }
};

main(int argc, char **argv)
{ PL_register_extensions_in_module("user", predicates);

  if ( !PL_initialise(argc, argv) )
    PL_halt(1);

  ...
}
ClioPatria (version V3.1.1-51-ga0b30a5)