]> Repositorios git - scryer-prolog.git/commitdiff
ENHANCED: flush output for impure I/O (format/[2,3], portray_clause/1 etc.)
authorMarkus Triska <[email protected]>
Sat, 25 Jul 2020 07:47:59 +0000 (09:47 +0200)
committerMarkus Triska <[email protected]>
Sat, 25 Jul 2020 07:49:02 +0000 (09:49 +0200)
Without this, we do not get a (timely) prompt in cases like:

    ?- format("press a key: ", []), get_single_char(C).

whereas for example write/1 already works in such cases:

    ?- write('press a key: '), get_single_char(C).
    press a key:

src/lib/format.pl

index 95a1a1dafb2e5af58ccb7a5b77065134cdc445da..31abe57c18c2bfeac67552d18a6a7fc4d00f5e1b 100644 (file)
@@ -377,7 +377,8 @@ format(Stream, Fs, Args) :-
         % we use a specialised internal predicate that uses only a
         % single "write" operation for efficiency. It is equivalent to
         % maplist(put_char(Stream), Cs). It also works for binary streams.
-        '$put_chars'(Stream, Cs).
+        '$put_chars'(Stream, Cs),
+        flush_output(Stream).
 
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 ?- phrase(cells("hello", [], 0, []), Cs).