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

unload_file behavior differs from prolog. #85

Open
allComputableThings opened this issue Apr 29, 2020 · 1 comment
Open

unload_file behavior differs from prolog. #85

allComputableThings opened this issue Apr 29, 2020 · 1 comment

Comments

@allComputableThings
Copy link

allComputableThings commented Apr 29, 2020

It seems I can use pyswip to load a .pl, but not unload one: [update]

from pyswip import Prolog
prolog = Prolog()

filename = "f"  # # f.pl contains just       foo(1,1).

next(prolog.query(filename.join(["load_files('", "',[])"])))
print(list(prolog.query("foo(X,1)")))  # ==> [{X:1}]

query = "unload_file('{}')".format(filename)
print(query)
next(prolog.query(query))

print(list(prolog.query("foo(X,1)")))  # ==> [{X:1}] -- should have failed with missing 'f'

The behavior I get from Prolog is:

?- load_files(f,[]).
true.

?- foo(X,1).
X = 1.

?- unload_file(f).    .
true.

?- foo(X,1).
ERROR: Undefined procedure: foo/2 (DWIM could not correct goal)

Is the different behavior here a bug? (I'd like to load and unload files to keep unit tests independent in Python).

@allComputableThings
Copy link
Author

Fixed a bug in the unload step ^^ above ^^.
prolog.query(unload_file('f'))
still fails to unload the name foo.

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

1 participant