Why is predicate traced when using "trace, predicate." but not when using "trace." then "predicate."

I’m confused why I see a call and exit port for this:

?- trace, findall(X, atom(X), Solution).
^  Call: (11) findall(_10664, atom(_10664), _10672) ? creep
^  Exit: (11) findall(_10664, user:atom(_10664), []) ? creep
Solution = [].

But not this:

?- trace.
true.

[trace]  ?- findall(X, atom(X), Solution).
Solution = [].

[trace]  ?-

I thought the first was just a shortcut but tracing is behaving differently. Anyone know why?

EDIT: Even more confusing is why the first example above doesn’t show an additional call port for findall/4 given that the source code it is calling seems to be this:

findall(Templ, Goal, List) :-
    findall(Templ, Goal, List, []).

findall(Templ, Goal, List, Tail) :-
    setup_call_cleanup(
        '$new_findall_bag',
        findall_loop(Templ, Goal, List, Tail),
        '$destroy_findall_bag').
1 Like