1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="hevea 1.08">
<LINK rel="stylesheet" type="text/css" href="gprolog.css">
<TITLE>
Predicate information
</TITLE>
</HEAD>
<BODY TEXT=black BGCOLOR=white>
<A HREF="gprolog030.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="gprolog023.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="gprolog032.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
<HR>
<H3 CLASS="subsection"><A NAME="htoc98">7.8</A> Predicate information</H3><UL>
<LI><A HREF="gprolog031.html#toc69"><TT>current_predicate/1</TT></A>
<LI><A HREF="gprolog031.html#toc70"><TT>predicate_property/2</TT></A>
</UL>
<A NAME="toc69"></A>
<H4 CLASS="subsubsection"><A NAME="htoc99">7.8.1</A> <TT>current_predicate/1</TT></H4>
<A NAME="current-predicate/1"></A>
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
current_predicate(?predicate_indicator)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>current_predicate(Pred)</TT> succeeds if there
exists a predicate indicator of a defined procedure that unifies with
<TT>Pred</TT>. All user defined procedures are found, whether static or
dynamic. Internal system procedures whose name begins
with <TT>'$'</TT> are not found. A user-defined procedure is found
even when it has no clauses. A user-defined procedure is not found if
it has been abolished. To conform to the ISO reference, built-in predicates
are not found except if the <TT>strict_iso</TT> Prolog flag is switched off (section <A HREF="gprolog045.html#set-prolog-flag/2">7.22.1</A>). This predicate is re-executable on
backtracking.<BR>
<BR>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Pred</TT> is neither a variable nor a predicate indicator</TD>
<TD VALIGN=top ALIGN=center NOWRAP> </TD>
<TD VALIGN=top ALIGN=left><TT>type_error(predicate_indicator, Pred)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Pred</TT> is a term <TT>Name/Arity</TT> and <TT>Arity</TT> is
neither a variable nor an integer</TD>
<TD VALIGN=top ALIGN=center NOWRAP> </TD>
<TD VALIGN=top ALIGN=left><TT>type_error(integer, Arity)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Pred</TT> is a term <TT>Name/Arity</TT> and <TT>Name</TT> is
neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP> </TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, Name)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Pred</TT> is a term <TT>Name/Arity</TT> and <TT>Arity</TT> is
an integer < 0</TD>
<TD VALIGN=top ALIGN=center NOWRAP> </TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(not_less_than_zero, Arity)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Pred</TT> is a term <TT>Name/Arity</TT> and <TT>Arity</TT> is
an integer > <TT>max_arity</TT> flag (section <A HREF="gprolog045.html#set-prolog-flag/2">7.22.1</A>)</TD>
<TD VALIGN=top ALIGN=center NOWRAP> </TD>
<TD VALIGN=top ALIGN=left><TT>representation_error(max_arity)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
ISO predicate.<BR>
<BR>
<A NAME="toc70"></A>
<H4 CLASS="subsubsection"><A NAME="htoc100">7.8.2</A> <TT>predicate_property/2</TT></H4>
<A NAME="predicate-property/2"></A>
<B>Templates</B>
<DL CLASS="list" COMPACT="compact"><DT CLASS="dt-list"><DD CLASS="dd-list"><TT>
predicate_property(?predicate_indicator, ?predicate_property)</TT></DL>
<B>Description</B><BR>
<BR>
<TT>predicate_property(Pred, Property)</TT> succeeds if there
exists a predicate indicator of a defined procedure that unifies with
<TT>Pred</TT> and if <TT>Property</TT> unifies with one of the properties of
the procedure. All user defined procedures and built-in predicates are
found. Internal system procedures whose name begins with <TT>'$'</TT>
are not found. This predicate is re-executable on backtracking.<BR>
<BR>
<B>Predicate properties</B>:
<UL CLASS="itemize"><LI CLASS="li-itemize"><TT>static</TT>: if the procedure is static.<BR>
<BR>
<LI CLASS="li-itemize"><TT>dynamic</TT>: if the procedure is dynamic.<BR>
<BR>
<LI CLASS="li-itemize"><TT>private</TT>: if the procedure is private.<BR>
<BR>
<LI CLASS="li-itemize"><TT>public</TT>: if the procedure is public.<BR>
<BR>
<LI CLASS="li-itemize"><TT>user</TT>: if the procedure is a user-defined procedure.<BR>
<BR>
<LI CLASS="li-itemize"><TT>built_in</TT>: if the procedure is a Prolog built-in predicate.<BR>
<BR>
<LI CLASS="li-itemize"><TT>built_in_fd</TT>: if the procedure is an FD built-in predicate.<BR>
<BR>
<LI CLASS="li-itemize"><TT>native_code</TT>: if the procedure is compiled in native code.<BR>
<BR>
<LI CLASS="li-itemize"><TT>prolog_file(File)</TT>: source file from which the
predicate has been read.<BR>
<BR>
<LI CLASS="li-itemize"><TT>prolog_line(Line)</TT>: line number of the source
file.</UL>
<B>Errors</B><BR>
<TABLE CELLSPACING=2 CELLPADDING=0>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Pred</TT> is neither a variable nor a predicate indicator</TD>
<TD VALIGN=top ALIGN=center NOWRAP> </TD>
<TD VALIGN=top ALIGN=left><TT>type_error(predicate_indicator, Pred)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Pred</TT> is a term <TT>Name/Arity</TT> and <TT>Arity</TT> is
neither a variable nor an integer</TD>
<TD VALIGN=top ALIGN=center NOWRAP> </TD>
<TD VALIGN=top ALIGN=left><TT>type_error(integer, Arity)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Pred</TT> is a term <TT>Name/Arity</TT> and <TT>Name</TT> is
neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP> </TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, Name)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Pred</TT> is a term <TT>Name/Arity</TT> and <TT>Arity</TT> is
an integer < 0</TD>
<TD VALIGN=top ALIGN=center NOWRAP> </TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(not_less_than_zero, Arity)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Pred</TT> is a term <TT>Name/Arity</TT> and <TT>Arity</TT> is
an integer > <TT>max_arity</TT> flag (section <A HREF="gprolog045.html#set-prolog-flag/2">7.22.1</A>)</TD>
<TD VALIGN=top ALIGN=center NOWRAP> </TD>
<TD VALIGN=top ALIGN=left><TT>representation_error(max_arity)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Property</TT> is neither a variable nor a predicate property
term</TD>
<TD VALIGN=top ALIGN=center NOWRAP> </TD>
<TD VALIGN=top ALIGN=left><TT>domain_error(predicate_property, Property)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Property</TT> = <TT>prolog_file(File)</TT> and <TT>File</TT>
is neither a variable nor an atom</TD>
<TD VALIGN=top ALIGN=center NOWRAP> </TD>
<TD VALIGN=top ALIGN=left><TT>type_error(atom, File)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR>
<TR><TD VALIGN=top ALIGN=left><TT>Property</TT> = <TT>prolog_line(Line)</TT> and <TT>Line</TT>
is neither a variable nor an integer</TD>
<TD VALIGN=top ALIGN=center NOWRAP> </TD>
<TD VALIGN=top ALIGN=left><TT>type_error(integer, Line)</TT></TD>
</TR>
<TR><TD BGCOLOR=black COLSPAN=3><TABLE BORDER=0 WIDTH="100%" CELLSPACING=0 CELLPADDING=1><TR><TD></TD></TR></TABLE></TD>
</TR></TABLE><BR>
<B>Portability</B><BR>
<BR>
GNU Prolog predicate.<BR>
<BR>
<HR SIZE=2>
Copyright (C) 1999-2007 Daniel Diaz
<BR>
<BR>
Verbatim copying and distribution of this entire article is permitted in any
medium, provided this notice is preserved. <BR>
<BR>
<A HREF="index.html#copyright">More about the copyright</A>
<HR>
<A HREF="gprolog030.html"><IMG SRC ="previous_motif.gif" ALT="Previous"></A>
<A HREF="gprolog023.html"><IMG SRC ="contents_motif.gif" ALT="Up"></A>
<A HREF="gprolog032.html"><IMG SRC ="next_motif.gif" ALT="Next"></A>
</BODY>
</HTML>
|