Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

current_predicate/1 does not work with :- dynamic?

I have some predicates that I define using asserts in Prolog.

I am using current_predicate/1 in order to know whether the assert has been run or not (only one value needs to be asserted).

However, swipl keeps complaining:

Warning: The predicates below are not defined. If these are defined
Warning: at runtime using assert/1, use :- dynamic Name/Arity.
Warning: 
Warning: amountOfStudentsInCourseAsserted/2, which is referenced by

So, I added the :- dynamic amountOfStudentsInCourseAsserted/2, but unfortunately, this adds the predicate to the current_predicate(Predicate).. Therefore I cannot use current_predicate/1 anymore if I am using this dynamic naming.

Is there another predicate like current_predicate/1that isn't true for dynamic names?

like image 250
Kevin Van Ryckegem Avatar asked Nov 27 '25 13:11

Kevin Van Ryckegem


1 Answers

You can use in alternative the predicate_property/2 built-in predicate and the number_of_clauses/1 property.

like image 145
Paulo Moura Avatar answered Nov 29 '25 16:11

Paulo Moura



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!