`predicate_property/2` doesn't support `static`,`public`,`private`
According to ISO/IEC 13211-1, every procedure is either public or private.
Also according to spec, every procedure is either static or dynamic.
These are not reported by predicate_property/2.
e.g.:
Should also report private and static for builtins:
?- predicate_property(fail,X).
X = built_in
; false.
e.g.:
Should also report private and static for library procedures that are not declared otherwise:
?- predicate_property(lists:length(_,_),A).
false.
e.g.:
Should also report public for dynamic procedures:
?- assertz(foo).
true.
?- predicate_property(foo,X).
X = dynamic
; false.
It seems (It's in Part 2!)predicate_property/2 would be a good candidate for inclusion in the standard? A good starting point is a comparison table that shows commonalities among existing implementations, and also parts where they currently differ.
~~It seems
predicate_property/2would be a good candidate for inclusion in the standard?~~
~~What do you mean?~~
It is in ISO/IEC 13211-2:
6.8 Predicate properties
The properties of procedures can be found using the built-in predicate
predicate_property(Callable, Property), whereCallableis the meta-argument termModule:Goal(7.2.2). The predicate properties supported shall include:
static-- The procedure is static.dynamic-- The procedure is dynamic.public-- The procedure is a public procedure.private-- The procedure is a private procedure.built_in-- The procedure is a built-in predicate.multifile-- The procedure is the subject of a multifile directive.exported-- the moduleModuleexports the procedure.metapredicate(MPMI)-- The procedure is a metapredicate, andMPMIis its metapredicate mode indicator.imported_from(From)-- The predicate is imported into moduleModulefrom the moduleFrom.defined_in(DefiningModule)-- The module with the nameDefiningModuleis the defining module of the procedure.A processor may support one or more additional predicate properties as an implementation specific feature.
Yes indeed, it's in Part 2, I initially overlooked it!
I initially overlooked it!
You had me questioning my sanity there!
I'm unclear at this point the status of predicate_property/2 vis-à-vis ISO/IEC 13211-2.
Is it intended to specify the standard predicate? Or is it a built-in implementation-specific predicate that happens to share a name?
It seems SICStus defines the predicate properties slightly differently per docs. It also doesn't define static, public, private either.
The various properties associated with Callable. Each loaded predicate will have one or more of the properties:
- one of the atoms
built_in(for built-in predicates) orcompiledorinterpreted(for user defined predicates) orfd_constraintfor indexical predicates see Section 10.9.13 [Defining Indexical Constraints], page 494.- the atom
dynamicfor predicates that have been declared dynamic (see Section 4.3.4.2 [Dynamic Declarations], page 88),- the atom
multifilefor predicates that have been declared multifile (see Section 4.3.4.1 [Multifile Declarations], page 87),- the atom
volatilefor predicates that have been declared volatile (see Section 4.3.4.3 [Volatile Declarations], page 88),- the atom
jittablefor predicates that are amenable to JIT compilation,- the atom
jittedfor predicates that have been JIT compiled,- one or more terms (block
Term) for predicates that have block declarations (see Section 4.3.4.5 [Block Declarations], page 88),- the atom
exportedor termsimported_from(ModuleFrom)for predicates exported or imported from modules (see Section 4.11 [ref-mod], page 165),- the term (
meta_predicate Term) for predicates that have meta-predicate declarations (see Section 4.11.16 [ref-mod-met], page 175).
Relevant discussion in #2933. Reading between the lines, it seems the property of being "public" in the ISO sense might not be as useful as it seemed at first blush.
I'm not sure whether that means it's not useful to have predicate_property/2 reflect this property.
On one hand, whether a predicate is unchangeable (dynamic) is semantically distinct from whether its implementation can be examined (public). On the other hand, in both Scryer and SICStus today, public and dynamic effectively coincide, so the distinction is useless.