0

In prolog, or at least in SWI-Prolog, you can load a file typing

[filename].

or

['filename.ext'].

or

[path/to/file].

or

['path/to/file.ext'].

However, I want to preprocess the file going to be loaded and therefore I need the content of above singleton lists to be a compatible file path, using it as first argument of open/3. What currently works:

  1. The hook to catch queries from REPL using expand_query/4
  2. Matching for singleton list expressions and binding the one element to a variable

What works not:

  • Using the in »2.« mentioned variable as +SrcDest for open/3.

So how can I process the quasi-path to a real path, such that any of the 4 above mentioned ways to load a module works?

false
  • 10,264
  • 13
  • 101
  • 209
user3389669
  • 799
  • 6
  • 20
  • 1
    Check the documentation of the `absolute_file_name/3` predicates at http://www.swi-prolog.org/pldoc/doc_for?object=absolute_file_name/3 – Paulo Moura Oct 18 '16 at 13:07
  • @PauloMoura Using `extensions(['.pl'])` as option to `absolute_file_name/3` works great – all four cases are handled this way. – user3389669 Oct 18 '16 at 13:40

0 Answers0