On 09/06/2026 17:30, Jose F. Morales wrote:
- failure, in case of a query about it
?- open('/tmp/myfile',write,S), close(S), current_input(S). false.
So, this indeed raises an existence error in current SWI-Prolog. I looked at it in a bit more detail. This raises some questions:
?- current_input(4.5) raises a domain error.
What should the call below do? After all, foo can be a stream alias name that either exists, has existed or has never existed.
?- current_input(foo).
Turning the above into failure also turns this into a failure. SICStus raises a domain error.
P.s. Although I think failing is logically more sound, systems must be able to safely deal with the ABA issue, i.e., a stream handle is closed and a new stream is opened using the same term. This cannot happen in SWI-Prolog because stream handles are "blobs" that are subject to Atom-GC and a stream handle can thus only be reclaimed after the old was reclaimed by atom-GC
Regards --- Jan