correct and generalize current_predicate/1

This commit is contained in:
Mark
2023-06-28 17:31:43 -06:00
parent c4b13a2176
commit 58af615dd4
4 changed files with 9 additions and 10 deletions

View File

@@ -1252,14 +1252,13 @@ abolish(Pred) :-
% It can be used to check for existence of a predicate or to enumerate all loaded predicates
current_predicate(Pred) :-
( var(Pred) ->
'$get_db_refs'(_, _, PIs),
'$get_db_refs'(_, _, _, PIs),
lists:member(Pred, PIs)
; '$strip_module'(Pred, Module, UnqualifiedPred),
( var(Module),
\+ functor(Pred, (:), 2)
; atom(Module)
),
nonvar(UnqualifiedPred),
UnqualifiedPred = Name/Arity ->
( ( nonvar(Name), \+ atom(Name)
; nonvar(Arity), \+ integer(Arity)

View File

@@ -70,9 +70,9 @@ _lists of characters_. This is an ideal representation:
file_exists/1,
directory_exists/1,
delete_file/1,
rename_file/2,
file_copy/2,
delete_directory/1,
rename_file/2,
file_copy/2,
delete_directory/1,
make_directory/1,
make_directory_path/1,
working_directory/2,

View File

@@ -16,8 +16,8 @@ but they're not part of the ISO Prolog standard at the moment.
setup_call_cleanup/3,
call_nth/2,
copy_term_nat/2,
asserta/2,
assertz/2]).
asserta/2,
assertz/2]).
:- use_module(library(error), [can_be/2,
domain_error/3,