scryer-prolog icon indicating copy to clipboard operation
scryer-prolog copied to clipboard

A way to detect all available predicates would be useful

Open triska opened this issue 1 year ago • 2 comments

Motivation: Precompile a set of facts that let us quickly recognize built-in predicates: https://github.com/mthom/scryer-prolog/discussions/2599

Which built-in predicates are there?

?- predicate_property(A, built_in).
   error(instantiation_error,predicate_property/2).

Ideally, predicate_property/2 would tell us.

current_predicate/1 cannot be used to obtain all predicates that are currently defined, because current_predicate/1 only succeeds for user-defined predicates.

triska avatar Oct 05 '24 09:10 triska

Well, I think this would go against the ISO Standard, see #153. I also think this would be saner behavior, but maybe we should add a different predicate in library(iso_ext) that does that so that current_predicate/1 is still ISO compliant.

EDIT: Oh, you already addressed that by putting the functionality in predicate_property/2 instead. Seems nice.

bakaq avatar Oct 05 '24 15:10 bakaq

Yes, good catch, I have already edited the original suggestion to suggest predicate_property/2 instead, because current_predicate/1 cannot be used for the reason you mention, thank you for spotting this!

triska avatar Oct 05 '24 16:10 triska