Normally, resources are defined as unit clauses (facts), but the definition of this predicate can also imply rules. For proper generation of the saved state generation, it must be possible to enumerate the available resources by calling this predicate with all its arguments unbound.
Dynamic rules can be useful to turn all files in a certain directory into resources, without specifying a resources for each file. For example, assume the file_search_path2 icons refers to the resource directory containing (XPM) icons. The following definition makes all these images available as resources:
open_resource3+Name, ?Class, -Stream Opens the resource specified by Name and Class. If the latter is a variable, it will be unified to the class of the first resource found that has tehe specified Name. If successful, Stream becomes a handle to a binary input stream, providing access to the content of the resource.
The predicate open_resource3 first checks resource3. When succesful it will open the returned resource source-file. Otherwise it will look in the programs resource database. When creating a saved-state, the system normally saves the resource contents into the resource archive, but does not save the resource clauses.
This way, the development environment uses the files (and modifications to the resource3 declarations and/or files containing resource info thus immediately affect the running environment, while the runtime system quickly accesses the system resources.