foreign/[2,3]
[hook]:- discontiguous foreign/2, foreign/3.
foreign(
+Routine,
+ForeignSpec)
foreign(
+Routine,
+Language,
+ForeignSpec)
Describes the interface between Prolog and the foreign Routine.
Used by load_foreign_resource/1
.
An atom that names a foreign code Routine.
An atom that names the Language
in which Routine is written. Can only be c
.
A ground term of the form PredName(Argspec, ..., Argspec) as described in Conversions between Prolog Arguments and C Types. Each Argspec should be a foreign_arg.
The user has to define a foreign/[2,3]
fact for every foreign function that
is to be called from Prolog. Note that Routine does not have to be
the same as PredicateName. Arguments are passed to the foreign function
as specified in ForeignSpec.
The foreign/[2,3]
facts are used only in the context of a
load_foreign_resource/1
command
and can be removed once the foreign files are loaded.
Contrary to most hook predicates which reside in the user
module,
foreign/[2,3]
facts will only be looked up
in the source module of the loading command.
Error handling is performed by load_foreign_resource/1
.
load_foreign_resource/1
, Calling C from Prolog.