{}/1

Description

{Goal}
{Closure}
{Term}

This control construct allows the programmer to bypass the Logtalk compiler (including its linter but not its optimizer) in multiple contexts:

  • Calling a goal as-is (from within an object or category) in the context of the user pseudo-object.

  • Extending a closure as-is with the remaining arguments of a call/2-N call in order to construct a goal that will be called within the context of the user pseudo-object.

  • Wrapping a source file term (either a clause or a directive) or a source file goal to bypass the term-expansion mechanism.

  • Using it in place of an object identifier when sending a message. In this case, its argument is proved as a goal within the context of the user pseudo-object with the resulting term being used as an object identifier in the message sending goal. This feature is mainly used with parametric objects when their identifiers correspond to predicates defined in user.

  • Using it as a message to an object. This is mainly useful when the message is e.g. a conjunction of messages, some of which being calls to Prolog built-in predicates.

Note

This control construct is opaque to cuts when used to wrap a goal (thus ensuring the same semantics independently of the argument being bound at compile time or at runtime).

Modes and number of proofs

{+callable} - zero_or_more

Errors

Goal is a variable:
instantiation_error
Goal is neither a variable nor a callable term:
type_error(callable, Goal)

Closure is a variable:
instantiation_error
Closure is neither a variable nor a callable term:
type_error(callable, Closure)

Term is a variable:
instantiation_error
Term is neither a variable nor a callable term:
type_error(callable, Term)

Examples

% overload the standard (<)/2 operator by
% calling its standard built-in definition:
N1/D1 < N2/D2 :-
    {N1*D2 < N2*D1}.

% call a closure in the context of "user":
call_in_user(F, X, Y, Z) :-
    call({F}, X, Y, Z).

% bypass the compiler for a proprietary backend directive:
{:- load_foreign_resource(file)}.

% use parametric object proxies:
| ?- {circle(Id, Radius, Color)}::area(Area).
...

% use Prolog built-in predicates as messages:
| ?- logtalk::{write('hello world!'), nl}.
hello world!
yes