Subject: Re: [SWIPL] Problem with dynamic facts

From: Jan Wielemaker <[email-masked]>
Date: Tue, 26 Feb 2002 11:15:01 +0100

On Tuesday 26 February 2002 11:01, zze-PEX SOR balc031 FTRD/DTL/CAE wrote:

[Please don't send attachments to the mailinglist]

> I've got a problem with a dynamic declaration of facts!
>
> In a prolog file, I defined a prolog predicate reduce/3 which calls facts
> deduce/5.
>
> From my C++ program, I can execute a query calling the predicate
> 'reduce/3'.
>
> If my base of facts is declare in the prolog file, expected result is
> correct.
>
> If facts are declare in my C++ program (with the 'assert/1' prolog
> predicate') instead,
> an exception is raised during execution:
>
> ERROR: Undefined procedure: deduce/5
> ERROR:     However, there are definitions for:
> ERROR:         reduce/3
>
> I think this appears because the 'reduce/3' prolog predicate can't find
> facts 'deduce/5'.
>
> I supposed this predicate should be declared as dynamic.
>
> So, I added the following line in my prolog file:
> :- dynamic
> 	deduce/5.
>
> ... but the expected result is not correct!

Assert/1 creates a predicate dynamic if no such predicate existed, so
the dynamic declaration is good practice, but won't help.  For some
reason the assert/1 call from your C++ program hasn't worked as you
expected, but as you give us no clue how you try to realise the
assert/1 from C++, there is little we can say about it. 

	Cheers --- Jan