Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load modules in a module exactly once? #2640

Open
jjtolton opened this issue Oct 22, 2024 · 2 comments
Open

Load modules in a module exactly once? #2640

jjtolton opened this issue Oct 22, 2024 · 2 comments

Comments

@jjtolton
Copy link

:- module(environment, /*...*/).

%% initialize global environment exactly once
term_expansion((:-> establish_context), (:-> context_established))
:-
        write('establishing context, you should only see this once!'),
        empty_assoc(Assoc),
        bb_put(global_context, Assoc).
            
:-> establish_context.

elsewhere...

:- module(common, /*...*/).
:- use_module(environment).
:- use_module(environment).

?- ['/home/jay/_project/tai/jlog/src/jlog/agent/bucketdomain/ediprolog-temp'].
establishing context, you should only see this once!establishing context, you should only see this once!   true.

😬

Is there any reason to consult a module multiple times? I imagine it could be consulted and then reference shared on subsequent look-ups, even across files.

@hurufu
Copy link
Contributor

hurufu commented Oct 22, 2024

Be careful with expansion, currently sometimes it is called multiple times for the same goal #2603

@hurufu
Copy link
Contributor

hurufu commented Oct 22, 2024

So it is not really good idea to rely on side-effects during goal (or term) expansion right now.

@jjtolton jjtolton changed the title Load modules in a module exactly one? Load modules in a module exactly once? Nov 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants