If I understand correctly, SSU syntax is borrowed from another language, and not (easily?) portable across Prologs.
And let’s consider this example for a moment:
ab_status(A,B,Status) :-
A, B, Status = both(A,B).
ab_status(A,B,Status) :-
A, \+B, Status = just_a(A).
ab_status(A,B,Status) :-
\+A, B, Status = just_b(B).
ab_status(A,B,Status) :-
\+A, \+B, Status = neither.
Rewriting the above using SSU wouldn’t omit the cost or repeated evaluations of A and B.
On the other hand, if we adhere to a consistent style of guards, we could refactor the above with a sort of “ssu indicator”
:- ssu(ab_status ...)
This would refactor ab_status
to something like:
ab_status(A,B,S) :-
(A -> true; NotA = true), ...,
(A, B, S=both) ;
(A, NotB, S=just_a) ;
(NotA, B, S=just_b(B)) ;
(NotA, \+NotB, S=neither)
This would be some (portable) rewriting for optimization. But it relies on convention and silently fails to optimize if the convention is not adhered to. Could one defend against creating an incorrect rewrite?
Does this seem at all fruitful or totally misguided?