I’m working on a relatively large prolog project. The amount of files has grown so much that I’d like to reorder the code a bit. So i thought of the following plan:
- group all existing source files into separate directories.
- have a single source file for each directory which re-exports all predicates in that directory through
reexport/1
. - modify all
use_module
directives so that they use the high-level reexporting module, rather than the smaller submodules inside the directories.
Unfortunately, after having done this refactor, things stop working, and I get lots of ‘Undefined procedure’ errors for predicates that should actually be resolvable. Funnily, reconsulting files containing predicates that error actually makes the problem go away.
I have no idea what is going wrong. I tried creating a minimal example where I create some toy modules that import and reexport, but can’t seem to recreate the problem.
Does this problem sound familiar to anyone? Does anyone have any idea what would cause a module to not find predicates in its dependencies on first consult, but then find them anyway on second consult?
This happens on 8.0.3.