From: SourceForge.net <no...@so...> - 2006-01-19 18:18:21
|
Support Requests item #1408853, was opened at 2006-01-18 08:59 Message generated for change (Comment added) made by tswift You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=201176&aid=1408853&group_id=1176 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Priority: 5 Submitted By: hugues (hugum) Assigned to: Nobody/Anonymous (nobody) Summary: How to return no for not declared predicate Initial Comment: 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 ---------------------------------------------------------------------- >Comment By: Terrance Swift (tswift) Date: 2006-01-19 18:18 Message: 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 ---------------------------------------------------------------------- Comment By: David S. Warren (dwarren) Date: 2006-01-18 17:38 Message: 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 ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=201176&aid=1408853&group_id=1176 |