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

save-space! gives existence error on get_atoms #191

Open
AdrickTench opened this issue Nov 15, 2024 · 0 comments
Open

save-space! gives existence error on get_atoms #191

AdrickTench opened this issue Nov 15, 2024 · 0 comments
Assignees
Labels
bug Issues that represent errors in the code

Comments

@AdrickTench
Copy link
Collaborator

save-space! gives an existence error for its internal method get_atoms.
e.g. !(save-space! &self "test-save-space.metta") will give an error

...
  Call: (85) [user] forall(get_atoms('&self', _214210), write_src(_214210))
^  Unify: (85) [$apply] forall(user:get_atoms('&self', _214210), user:write_src(_214210))
   Call: (86) [user] get_atoms('&self', _214210)
% Got uncaught (guard = 'C') exception existence_error(procedure,get_atoms/2) (Ctx0='$apply':forall/2)
   Exception: (86) [user] get_atoms('&self', _214210) ? goals
     [86] [user] get_atoms('&self', _214210)
     [85] [$apply] forall(user:get_atoms('&self', _214210), user:write_src(_214210))
     [84] [system] '$c_call_prolog'
     [83] [user] with_output_to(<stream>(0x56494c26eba0), forall(get_atoms('&self', _214210), write_src(_214210)))
     [82] [system] setup_call_cleanup(user:open("my-test.metta", write, <stream>(0x56494c26eba0), []), user:with_output_to(<stream>(0x56494c26eba0), forall(get_atoms('&self', _214210), write_src(_214210))), user:close(<stream>(0x56494c26eba0)))
   Exception: (86) [user] get_atoms('&self', _214210) ?

The implementation

'save-space!'(Space, File) :-
    setup_call_cleanup(
        % Open the specified File in write mode.
        open(File, write, Out, []),
        % Write all atoms from the Space to the file using with_output_to/2.
        with_output_to(Out,
            % For each atom retrieved from the space, write it to the file.
            forall(get_atoms(Space, Atom), write_src(Atom))),
        % Ensure the output stream is closed after writing.
        close(Out)).
@AdrickTench AdrickTench added the bug Issues that represent errors in the code label Nov 15, 2024
@TeamSPoon TeamSPoon self-assigned this Nov 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issues that represent errors in the code
Projects
None yet
Development

No branches or pull requests

2 participants