 current_predicate(?Name, 
:Head)
current_predicate(?Name, 
:Head)
call_if_exists(G) :-
        current_predicate(_, G),
        call(G).
Because of this intended usage, current_predicate/2 also succeeds if the predicate can be autoloaded. Unfortunately, checking the autoloader makes this predicate relatively slow, in particular because a failed lookup of the autoloader will cause the autoloader to verify that its index is up-to-date.