In one of my programs, I try to locate a file using:
absolute_file_name(home(some), Some).
false
This is in SWI-Prolog (threaded, 64 bits, version 9.0.2).
It looks like the alias ‘home’ is not defined, though I believe it was in a previous version of Prolog.
I know there is a work around by adding :
A user could have countless files & directories for other purposes, under $HOME. I’d call it bad practice to not put Prolog files in some sort of subdirectory order.
user_app_data looks like a sensible place to put Prolog files, as seen at file_search_path/2
Thanks for this link.
I am actually aware of how absolute_file_name/2 should work in relation with file_search_path/2.
My point, again, is that, unless I am wrong, swipl knew about a file_search_path of home.
i.e. in a previous version, the following query yielded Home= instead of failing.
Welcome to SWI-Prolog (threaded, 64 bits, version 9.0.2)
SWI-Prolog comes with ABSOLUTELY NO WARRANTY. This is free software.
Please run ?- license. for legal details.
For online help and background, visit https://www.swi-prolog.org
For built-in help, use ?- help(Topic). or ?- apropos(Word).
?- file_search_path(home, Home).
false.
When I wrote that Wiki the SWI-Prolog documentation noted in absolute_file_name/3 for the option expand(Boolean)
This is a SWI-Prolog extension intended to minimise porting effort after SWI-Prolog stopped expanding environment variables and the ~ by default.
which would seem to confirm your suspicions.
When I started using user:file_search_path/N and absolute_file_name/3 I too thought that most code would be referenced from home or in my case on Windows C:\Users\Groot. But after having learned about prolog_load_context/2 I now add a directive like
to any of my code that is more than one file. This also makes the code much more portable as it can transition to other users, other install locations and other operating systems, just works and is no longer dependent on environment variables such as home.