Thanks, that resolves it. To confirm I've understood: a closed handle
is still a stream-term (the right kind of term), so the domain_error
clause of 8.11.1.3 does not apply. Since current_input/1 is a query,
it simply fails. I've checked that GNU Prolog works that way. SICStus,
Trealla, or SWI does not.
Just to follow:
- current_input/1 lists only domain_error(stream, S) and no
existence_error.
So SWI returning existence_error(stream, S) here raises an error the
predicate's table does not allow.
- By your reasoning, SICStus's domain_error(stream, S) is equally
non-conforming for a closed handle: domain_error is appropriate
only when the term can never be a stream-term, which a closed
handle can be. That is what some conformance suite currently
(incorrectly?) encodes as the expected result, e.g. LogTalk:
https://github.com/LogtalkDotOrg/logtalk3/blob/36a64c4d24448813af25c48a1966c0010434cec4/tests/prolog/predicates/current_input_1/tests.lgt#L44 https://github.com/LogtalkDotOrg/logtalk3/blob/36a64c4d24448813af25c48a1966c0010434cec4/tests/prolog/predicates/current_input_1/tests.lgt#L37 - stream_property/2 only lists domain_error(stream, S), no existence_error.
I understand that stream_property/2 on a closed stream must also
fail and not raise an existence error. Same suite's expectation for
the closed-handle cases:
https://github.com/LogtalkDotOrg/logtalk3/blob/36a64c4d24448813af25c48a1966c0010434cec4/tests/prolog/predicates/stream_property_2/tests.lgt#L176 https://github.com/LogtalkDotOrg/logtalk3/blob/36a64c4d24448813af25c48a1966c0010434cec4/tests/prolog/predicates/stream_property_2/tests.lgt#L180