From bd829946edfa3c5e028fc6f5557fde07f792e683 Mon Sep 17 00:00:00 2001 From: Vitor Santos Costa Date: Sat, 28 Mar 2015 19:42:10 +0000 Subject: [PATCH] autoloading is an import, like any other --- pl/modules.yap | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/pl/modules.yap b/pl/modules.yap index d4a1ce35e..55108cf3b 100644 --- a/pl/modules.yap +++ b/pl/modules.yap @@ -833,6 +833,8 @@ expand_goal(G, G). % This predicate should be bidirectional: both % a consumer and a generator. +'$get_undefined_pred'(G, ImportingMod, call(G), ImportingMod) :- + var(G), !. '$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :- recorded('$import','$import'(ExportingModI,ImportingMod,G0I,G,_,_),_), '$continue_imported'(ExportingMod, ExportingModI, G0, G0I). @@ -847,11 +849,14 @@ expand_goal(G, G). call(Dialect:index(Name,Arity,ExportingModI,_)), !, '$continue_imported'(ExportingMod, ExportingModI, G0, G). % autoload -'$get_undefined_pred'(G, _ImportingMod, G0, ExportingMod) :- +'$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :- yap_flag(autoload, V), V = true, - '$autoloader_find_predicate'(G,ExportingModI), - '$continue_imported'(ExportingMod, ExportingModI, G0, G). + functor(G, N, K), + functor(G0, N, K), + '$autoloader_find_predicate'(G0,ExportingMod), + ExportingMod \= ImportingMod, + (recordzifnot('$import','$import'(ExportingMod,ImportingMod,G0,G0, N ,K),_) -> true ; true ). % parent module mechanism '$get_undefined_pred'(G, ImportingMod, G0, ExportingMod) :- prolog:'$parent_module'(ImportingMod,ExportingModI),