Paulo Moura wrote:
Nice to ear from you again.
Likewise!
Is this because I'm not using these features correctly or could it be they're not compatible?
Ooops. It's my fault. I missed out the category import so the existence error was perfectly correct. With that corrected, it appears to work fine.
Paulo Moura wrote:
I guess you're defining clauses for goal_expansion/2 in your hook object. You need to add a clause for :/1 goals. The same for ::/1 goals. For example:
Code: Select all
goal_expansion(::Goal, ::ExpandedGoal) :-
nonvar(Goal), % sanity check for prevening endless loops
goal_expansion(Goal, ExpandedGoal).
goal_expansion(:Goal, :ExpandedGoal) :-
nonvar(Goal), % sanity check for prevening endless loops
goal_expansion(Goal, ExpandedGoal).
goal_expansion(..., ...).
I'm surprised that your code works for ::/1 calls but it's hard to explain without seeing your hook code.
The hook code doesn't specifically address ::/1 calls. BTW, the code should look familiar to you
Code: Select all
hook((Head :- Body), [(Head :- TBody)]) :-
conjunction(Body, TBody).
conjunction((Goal1; Goal2), (TGoal1; TGoal2)) :-
!,
conjunction(Goal1, TGoal1),
conjunction(Goal2, TGoal2).
conjunction((Goal1 -> Goal2), (TGoal1 -> TGoal2)) :-
!,
conjunction(Goal1, TGoal1),
conjunction(Goal2, TGoal2).
conjunction(\+ (Goal, Goals), \+ (TGoal, TGoals)) :-
!,
conjunction(Goal, TGoal),
conjunction(Goals, TGoals).
conjunction((Goal, Goals), (TGoal, TGoals)) :-
!,
conjunction(Goal, TGoal),
conjunction(Goals, TGoals).
conjunction(\+ Goal, \+ TGoal) :-
!,
transform(Goal, TGoal).
conjunction(Goal, TGoal) :-
transform(Goal, TGoal).
% replace bb_put/2 with true
transform(bb_put(_,_),true) :- !.
% replace bb_get/2 with true
transform(bb_get(_,_),true) :- !.
% replace number_atom/2 with true
transform(number_atom(_,_),true) :- !.
transform(Goal, Goal).
goal_expansion(bb_put(_,_),true).
goal_expansion(bb_get(_,_),true).
goal_expansion(number_atom(_,_),true).
Paulo Moura wrote:
Hope this helps. Let me know if the solution above solves your problem. Cheers,
Paulo
Thanks Paulo. Curiously, preliminary testing shows no noticeable speed improvement for my code. Perhaps there are no :/1 calls on the critical path (although I doubt this). Is it possible static binding is not being used for some reason? To test this I compared compiled code when switching from ::/1 to :/1 and the calls to $lgt_send_to_self_nv are removed, which seems to be correct. I suppose I was over-optimistic about the improvement. However my results are consistent with your benchmarks (c2 vs c1) here
http://logtalk.org/performance.html
Running Logtalk: 2.32.2 on SWI 5.6.57
Cheers,
Parker,
FYI: reply notification is not working on this forum even when subscribed to a topic - just in case you didn't know.