Dear,
Consider the folowing rules and fact:
person(Person):-female(Person).
person(Person):-male(Person).
female(jane).
The goal "?- person(P)." gives :
P = jane
++Error[XSB/Runtime/P]: Undefined predicate: male/1
Forward Continuation...
... machine:xsb_backtrace/1
... loader:load_pred1/1
... loader:load_pred0/1
... loader:load_pred/1
etc...
How can I declare that male/1 is defined and false?
A solution is to manualy declare
:-dynamic male/1.
But if my facts contain a male, there is
a conflict :
"Not permitted to assert to static predicate male/1"
Is there an automatic way to declare a predicate as dynamic
if it does not exists in the base of facts (staticaly)?
In fact my problem is very more complex and it is
not possible to declare all the dynamic predicates
manualy for each base of facts.
Thanks for your help, best regards,
Hugues Malgouyres
Logged In: YES
user_id=13069
Up until now, XSB had no way to do this. But this morning
I've added that capability according to the ISO standard.
So if you get the current CVS version of XSB (checkout
anonymous, configure and compile), then you can do:
| ?- set_prolog_flag(unknown,fail).
After setting this flag this way, calling an undefined
predicate will quietly fail.
You can also set it to error (the default), or warning
(which will print a warning and fail.)
-David
Logged In: YES
user_id=13011
David's fix is certainly the best one to use. However, if you want to
stick to 2.7.1 for some reason, you might be able to use the following
cumbersome work-around. Put your file into a module (e.g. foo) and
then execute
try_this:-
current_functor(foo:F/A),
functor(Term,F,A),
\+ predicate_property(Mod:Term,loaded),
\+ predicate_property(Mod:Term,imported_from(Mod)),
dynamic(foo:F/A),
fail.
This works in some simple test cases, and with a little elaboration
(see the manual) may do what you need. But again, using the ISO fix
would be best.
Terry
Logged In: YES
user_id=13011
Originator: NO
This has been addressed, so I'm closing it out.