diff --git a/docs/yap.tex b/docs/yap.tex index 02d8e9b1d..20e812b55 100644 --- a/docs/yap.tex +++ b/docs/yap.tex @@ -8505,7 +8505,9 @@ Stream currently being read in. @item term_position @findex file (prolog_load_context/2 option) @* -Stream position at the stream currently being read in. +Stream position at the stream currently being read in. For SWI +compatibility, it is a term of the form +@code{'$stream_position'(0,Line,0,0,0)}. @end table @item source_location(?@var{FileName}, ?@var{Line}) diff --git a/pl/consult.yap b/pl/consult.yap index 072b1892d..4e48341bd 100755 --- a/pl/consult.yap +++ b/pl/consult.yap @@ -495,9 +495,11 @@ prolog_load_context(source, FileName) :- nb_getval('$consulting_file',FileName). prolog_load_context(stream, Stream) :- '$fetch_stream_alias'(Stream,'$loop_stream'). -prolog_load_context(term_position, Position) :- - '$fetch_stream_alias'(Stream,'$loop_stream'), - stream_position(Stream, Position). +% return this term for SWI compatibility. +prolog_load_context(term_position, '$stream_position'(0,Line,0,0,0)) :- + '$fetch_stream_alias'(Stream,'$loop_stream'), !, + stream_property(Stream, position(Position)), + stream_position_data(line_count, Position, Line). % if the file exports a module, then we can