Macro swipl_macros::prolog
source · prolog!() { /* proc-macro */ }
Expand description
Define prolog predicates to be used from rust code.
The prolog!
macro takes a block of function declaration. Each
declaration is of the format fn <predicate>(..args..);
, where
args is a list of argument names. Optionally, a visibility
specifier like pub
may be used. This much like an ordinary rust
function declaration, except that the arguments are typeless.
Each function may be annotated with a #[name("..name..")]
attribute, which specifies what the name of this predicate is in
prolog. When omitted, the function name will be used.
Each function may be annotated with a #[module("..module..")]
attribute, which specifies what prolog module this predicate is
in. When omitted, no module is assumed.
For each function declaration, a function will be generated which takes a context argument, followed by all declared arguments, and returns a query opened in that context.
Example:
prolog! {
fn writeq(term);
#[name("nl")]
fn print_a_newline();
#[module("zlib")]
pub fn zopen(stream, zstream, options);
}