Well, you avoid double evaluation. You do pay a price in time (tabled execution needs to maintain tables and is thus slower if you get no profit from its reusing its tables) and notably in memory. Finally, truth maintenance is harder: if bar/1 somehow depends on anything buts its arguments you must be sure its tables are properly invalidated and recomputed. So, in general I don’t think this is a wise replacement.
If the condition is sufficiently ground, the if-then-else has a nice logical reading. (And it’s possible to extend this idea, using freeze/2 or when/2.)
It’s unfortunate that Prolog doesn’t have a way of marking the last clause as an “otherwise”.
:- use_module(library(reif)).
baz(X) :-
if_(bar(X), foo(X), mep(X)).
foo(1) :- writeln(foo).
mep(2) :- writeln(mep).
% Notice you provide the boolean output of the condition as the
% last output argument (this is called reifying the truth value)
bar(1,true).
bar(2,false).
Notice you have to reify the truth or falsity of the condition (bar/2). This means you make the truth value be an output argument of the predicate. The value is true if the condition is true, or false if it is false.
The best I can find are the links to SO answers from his SO user page which explain each predicate in detail with examples. Look at the info and scroll down to find some of the links.
Paragraph copied here on 09/09/2019 for those who can’t find the links.