Skip to content

unload_file behavior differs from prolog. #85

@allComputableThings

Description

@allComputableThings

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).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions