Logtalk reference manual
Built-in method: clause/2
clause/2
Description
clause(Head, Body)
Enumerates, by backtracking, the clauses of an object's dynamic predicates.
This method may be used to enumerate clauses for predicates that are not declared dynamic for dynamic objects provided that the predicates are declared in this.
Template and modes
clause(+callable, ?body)
Errors
- Head is a variable:
instantiation_error
- Head is a neither a variable nor a callable term:
type_error(callable, Head)
- Body is a neither a variable nor a callable term:
type_error(callable, Body)
- The predicate indicator of Head, Functor/Arity, is that of a private predicate:
permission_error(access, private_predicate, Functor/Arity)
- The predicate indicator of Head, Functor/Arity, is that of a protected predicate:
permission_error(access, protected_predicate, Functor/Arity)
- The predicate indicator of Head, Functor/Arity, is that of a static predicate:
permission_error(access, static_predicate, Functor/Arity)
- Head is not a declared predicate:
existence_error(predicate_declaration, Functor/Arity)
Examples
- To retrieve a matching clause of any dynamic predicate in this:
clause(Head, Body)
- To retrieve a matching clause of a public or protected dynamic predicate in self:
::clause(Head, Body)
- To retrieve a matching clause of a public dynamic predicate in an explicit object:
Object::clause(Head, Body)