Created
May 16, 2014 21:55
-
-
Save mndrix/698f3a3c2d12b8f14021 to your computer and use it in GitHub Desktop.
Experiments with Prolog imports and exports from modules
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- module(bar, [ bar_a/0 ]). | |
do_import(TargetModule) :- | |
%TargetModule:use_module(bar, [bar_a/0]). | |
%TargetModule:import(bar:bar_a/0). | |
TargetModule:assert((bar_a :- writeln("Asserted bar_a/0"))). | |
bar_a :- | |
writeln("Inside bar_a/0"). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:- module(foo, []). | |
main :- | |
writeln("Loading bar module"), | |
load_files(bar,[if(not_loaded),must_be_module(true),imports([])]), | |
writeln("We don't have bar_a/0 yet"), | |
\+ current_predicate(foo:bar_a/0), | |
writeln("Asking bar to perform an import"), | |
bar:do_import(foo), | |
writeln("We do have bar_a/0 now"), | |
current_predicate(foo:bar_a/0), | |
writeln("Calling bar_a/0"), | |
bar_a. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment