Meta-predicates #230
Replies: 6 comments 25 replies
-
There should be no differences (other than performance). Can you post a reproducible example and the errors you get? Is there a public repo with the code? Wondering if you're calling SWI-Prolog library meta-predicates (if so, take a look at the Logtalk |
Beta Was this translation helpful? Give feedback.
-
Possibly related: #143 |
Beta Was this translation helpful? Give feedback.
-
Thank you for your very quick replies!
should compute a list of different numbers, some positive, some negative. |
Beta Was this translation helpful? Give feedback.
-
I found why you get different results between compiling the code in normal mode vs compiling the code in optimal mode. Your meta-predicate declarations are incorrect as the meta-argument in the :- meta_predicate(compute_gradients(*,::,*)). Also, you don't need the :- use_module(library(aggregate),[]). |
Beta Was this translation helpful? Give feedback.
-
The code you shared suggests an application of the many worlds design pattern. See e.g. https://logtalk.org/2019/11/13/many-worlds-design-pattern.html |
Beta Was this translation helpful? Give feedback.
-
Btw, why: compute_gradients(Head,WeightedClauses,Gradients) :-
findall(Gradient,(
term::varnumbers((Head,WeightedClauses),(ReHead,ReWeightedClauses)),
compute_gradients_aux(ReHead,ReWeightedClauses,Gradient)),
Gradients). instead of: compute_gradients(Head,WeightedClauses,Gradients) :-
term::varnumbers((Head,WeightedClauses),(ReHead,ReWeightedClauses)),
findall(Gradient, compute_gradients_aux(ReHead,ReWeightedClauses,Gradient)), Gradients). |
Beta Was this translation helpful? Give feedback.
-
I am currently porting a statistical relational machine learning system from plain Prolog to Logtalk, and I have managed to reproduce the original system's behaviour on SWI in normal compilation mode. However, when loading with the optimized flag to "on", Logtalk throws existence errors on queries whose behaviour was correct in normal mode.
It seems to have to do with the resolution of meta-predicates, and the calling contexts of goals within them.
My questions:
Are there known discrepancies here between optimized and normal compilation mode?
Does anyone have any experience as to how best to debug such errors, given that they don't occur in any debug mode?
Beta Was this translation helpful? Give feedback.
All reactions