static PL_option_t mypred_options[] = { PL_OPTION("quoted", OPT_BOOL), PL_OPTION("length", OPT_SIZE), PL_OPTION("callback", OPT_TERM), PL_OPTIONS_END }; static foreign_t mypred(term_t a1, term_t options) { int quoted = FALSE; size_t length = 10; term_t callback = 0; if ( !PL_scan_options(options, 0, "mypred_options", mypred_options, "ed, &length, &callback) ) return FALSE; <implement mypred> }
The only defined value for flags is currently OPT_ALL
,
which causes this function to raise a domain error if an option is
passed that is not in specs. Default in SWI-Prolog is to
silently ignore unknown options, unless the Prolog flag iso
is true
. The opttype argument defines the type
(group) of the options, e.g., "write_option"
. Option types
are defined by the ISO standard. SWI-Prolog only uses this if OPT_ALL
is specified, to raise a domain_error
of the indicated type
if some option is unused. The type name is normally the name of the
predicate followed by
_option
or the name of a representative of a group of
predicates to which the options apply.
Defined option types and their corresponding pointer type are described below.
OPT_BOOL
int
- Convert the option value to a bool. This converts the values described by