Check existence of clause 
Author Message
 Check existence of clause

On  21 de Jan de 1997 13:29, Dirk Richarz

Quote:

>first of all there is a difference between predicates that have no
>definition and therefore are unknown to the system and those predicates
>that have no clauses at the moment. The latter case is meaningful e.g.
>for dynamic predicates (declared by dynamic/2). As far as I know calls
>to predicates that have no clauses are not caught by the system. They
>have to be controlled by user predicates.

No, a predicate can have no definition and be known be the system if it
appears in a multifile/1 or a discontiguous/1 directive. For example, if
you load the following program:

----
:- discontiguous( foo/1 ).
----

and then you try:

----
?- foo(_).
no.
----
you don't get any error even if the prolog flag is set to raise an error
for unknown predicates (in this case foo/1 is a static predicate with no
clauses). This of course only happens if the Prolog compiler that you are
using conforms to the ISO standard...

Regards,

Paulo

----------------------------------------------------
Paulo Moura
Dep. of Mathematics, University of Coimbra, Portugal

http://www.*-*-*.com/
----------------------------------------------------



Sat, 10 Jul 1999 03:00:00 GMT  
 Check existence of clause

Quote:

> ----
> :- discontiguous( foo/1 ).
> ----

> and then you try:

> ----
> ?- foo(_).
> no.
> ----
> you don't get any error even if the prolog flag is set to raise an error
> for unknown predicates (in this case foo/1 is a static predicate with no
> clauses). This of course only happens if the Prolog compiler that you are
> using conforms to the ISO standard...

Hi,

dynamic/2 was only one out of a set of possible predicates. Using
multifile/1 or discontigous/1 also tells the prolog system that there
will be a particular predicate - in our case foo/1 - that may appear
somewhere (it depends on the declaring predicate where and how foo/1
will be found).
For the prolog system it is important that foo/1 has been mentioned by
calling one of these particular system predicates. This is enough in
order to avoid existence errors.

Dirk.

************************************************************************
  Dirk Richarz                    *
  University of Koblenz-Landau    *

  56075 Koblenz                   * phone: +49-261-9119-469
  Germany                         * fax:   +49-261-9119-465
************************************************************************



Sun, 11 Jul 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Check existence of clause

2. How to check a given class for existence?

3. Checking for file existence in labview 6.1

4. Checking for the existence of a file.

5. Checking File Existence in Regina ReXX Win95

6. Checking for existence of directories

7. check for file/directory existence

8. Directory existence check

9. Check existence of dsname with wildcards

10. checking the existence of a fiel

11. Checking File Existence in Quintus PROLOG

12. Check for existence and then add to TreeCtrl

 

 
Powered by phpBB® Forum Software