Remove redundant alias resolution in at_end_of_stream/1, add corresponding tests for null streams

Also fixed at_end_of_stream/0 leaving a choicepoint.
This commit is contained in:
Emilie Burgun
2025-02-07 14:59:32 +01:00
parent 8966e175f1
commit f45b0bcfe8
3 changed files with 78 additions and 12 deletions

View File

@@ -2188,12 +2188,10 @@ stream_property(S, P) :-
%% at_end_of_stream(+Stream).
%
% True iff the stream Stream has ended
at_end_of_stream(S_or_a) :-
( var(S_or_a) ->
at_end_of_stream(S) :-
( var(S) ->
throw(error(instantiation_error, at_end_of_stream/1))
; atom(S_or_a) ->
stream_property(S, alias(S_or_a))
; S = S_or_a
; true
),
stream_property(S, end_of_stream(E)),
( E = at -> true ; E = past ).
@@ -2205,7 +2203,7 @@ at_end_of_stream :-
current_input(S),
stream_property(S, end_of_stream(E)),
!,
( E = at ; E = past ).
( E = at -> true ; E = past ).
%% set_stream_position(+Stream, +Position).
%