11.3.114 load_foreign_resource/1 [hookable]

Synopsis

load_foreign_resource(:Resource)

Load the foreign resource Resource into Prolog. Relies on the hook predicates foreign_resource/2 and foreign/3.

Arguments

:Resource
file_spec, must be ground

The foreign resource to be loaded. The file extension can be omitted.

Description

load_foreign_resource/1 takes a foreign resource and loads it into Prolog.

The extension can be omitted from the filename given in the Resource argument.

Uses the foreign/3 and foreign_resource/2 facts defined by the user to make the connection between a Prolog procedure and the foreign function. In this context, the resource name is derived from Resource name by deleting any leading path and extension from the absolute file name of Resource.

When loading the foreign resource, it looks for a foreign_resource/2 fact for the resource name. For each symbol in that fact, it looks for a foreign/3 fact that gives the name of the Prolog procedure associated with the foreign symbol and the argument specification.

Contrary to most hook predicates which reside in the user module, load_foreign_resource/1 will look for foreign_resource/2 and foreign/3 facts defined in its source module.

Foreign resources are created with the splfr tool (see The Foreign Resource Linker).

Exceptions

Errors in the specification of foreign/[2,3] and foreign_resource/2 will all be reported when load_foreign_resource/1 is called.

See Also

foreign/[2,3], Foreign Resources, Calling C from Prolog.


Send feedback on this subject.