I just came across setup_call_cleanup/3 as a possible solution to do what I
>want. A question about the documentation:
>
>"Note that it is impossible to implement this predicate in Prolog other than by
>reading all terms into a list, close the file and call member/2."
>
>Does this mean that setup_call_cleanup does in fact read all terms into a list,
>close the file and call member/2, or does that mean it would have to do those
>things if it were implemented in the Prolog language, but actually it's
>implemented in C so it isn't implemented that way?
It should read rather like:
|Note that it is impossible to implement this predicate in Prolog. The
|closest approximation would be to read all terms into a list, close
|the file and call member/2.
There is no way to implement setup_call_cleanup/3 in Prolog directly
(except you do everything by meta-interpretation).
Please note also, that call_cleanup/2 should rather not be used at
all. Asynchronous interrupts that happen between opening the
file/connection and the installation of the cleanup handler would
produce memory or resource leakage.
Thank for pointing this out.
_______________________________________________
SWI-Prolog mailing list
SWI-Prolog@...
https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog