control construct
(@)/1
ï
Descriptionï
@Predicate
Calls a predicate definition in this. The argument must be a callable term at compile-time. The predicate must be declared (by a scope directive). This control construct provides access to predicate definitions in this from categories. For example, it allows overriding a predicate definition from a complementing category with a new definition that calls goals before and after calling the overridden definition (the overriding definition is sometimes described in other programming languages as an around method). When used within an object, itâs the same as calling its argument.
Modes and number of proofsï
@ +callable - zero_or_more
Errorsï
Predicate
, with predicate indicator Name/Arity
, is not declared:existence_error(predicate_declaration, Name/Arity)
Examplesï
Assuming an object declaring a make_sound/0
predicate, define an
around method in a complementing category:
make_sound :-
write('Started making sound...'), nl,
@make_sound,
write('... finished making sound.'), nl.