FYI for those wondering how to track down source code when it passes from Prolog to C.
Normally to see the code behind a documented predicate just go to the SWI-Prolog documentation page and click on
E.g.
For append/2, links to append/2 source code
Note: is at the right of
However for atom_length/2 it shows.
So the documentation will not help at this point the source code has to be searched.
The source code is on GitHub with two repositories for SWI-Prolog
- Dev - GitHub - SWI-Prolog/swipl-devel: SWI-Prolog Main development repository
- Stable - GitHub - SWI-Prolog/swipl: SWI-Prolog stable releases
Typically ones SWI-Prolog version is in sync with the latest SWI-Prolog development release so that repository will be used.
Browse to the GitHub repository for SWI-Prolog development.
(https://github.com/SWI-Prolog/swipl-devel
)
In the upper left search box
enter the search word: atom_length
and press enter.
On the left at the bottom click Advanced search
For Written in this language
select: C
Click Search
This shows the C implementation of atom_length/2 is in the src
directory and pl-prims.c
file.
A more efficient way I have found to search for such is to use Notepad++ to search a directory of local copies of GitHub repositories. A bit more details are in this reply.