Logtalk built-in method: clause/2

contents > reference manual > built-in methods

## `clause/2`

#### Description

>     clause(Head, Body)

> Enumerates, by backtracking, the clauses of an object's dynamic predicates.

#### 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 is that of a private predicate:
>   `permission_error(access, private_predicate, Head)`
> The predicate indicator of Head is that of a protected predicate:
>   `permission_error(access, protected_predicate, Head)`
> The predicate indicator of Head is that of a static predicate:
>   `permission_error(access, static_predicate, Head)`
> Head is not a declared predicate:
>   `existence_error(predicate_declaration, Head)`

#### 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 object:
>   `Object::clause(Head, Body)`

previous | glossary | next
Copyright © Paulo Moura — Logtalk.org