Assert and modules

Hello,

i experiencing unexpected behavior in that code in one module that eventually leads to an assert to be called in another module, seems to “loose” the asserted facts.

I.e. despite seeing them asserted during debugging, the facts are not retrieved or findable in the toplevel.

I am wondering whether its due to how modules work.

any thoughts might be much appreciated,

thank you,

Dan

Details, details, details, …

1 Like

SWI facts can be in a module or not. If you think they were added to module x, you can query it by going x:fact(Argument). You can also chose to assert in another module explicitly by doing assert(y:fact(3)).

2 Likes

My apology — that was my error – i used an incorrect predicate, which caused the problem. i have two variants of initalizations one that retracts all facts and another that only recreates a helper data structure – i used the former instead of the latter.

thank you,

Dan

grossdan

    February 13

Hello,

i experiencing unexpected behavior in that code in one module that eventually leads to an assert to be called in another module, seems to “loose” the asserted facts.

I.e. despite seeing them asserted during debugging, the facts are not retrieved or findable in the toplevel.

I am wondering whether its due to how modules work.

Be sure at the top-level (which starts in the module user) that you prefix the asserted predicate name with the desired module, as:

my_module:asserted_predicate(...)