goal expansion for format/2 and format/3
In this way, we benefit from partial evaluation of format strings.
This commit is contained in:
@@ -451,9 +451,11 @@ digits(uppercase, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ").
|
|||||||
% advantage of this is that an ideal implementation writes the
|
% advantage of this is that an ideal implementation writes the
|
||||||
% characters as they become known, without manifesting the list.
|
% characters as they become known, without manifesting the list.
|
||||||
|
|
||||||
format(Fs, Args) :-
|
format(_, _) :- not_used.
|
||||||
current_output(Stream),
|
|
||||||
format(Stream, Fs, Args).
|
user:goal_expansion(format(Fs, Args),
|
||||||
|
( current_output(Stream),
|
||||||
|
format(Stream, Fs, Args))).
|
||||||
|
|
||||||
%% format(Stream, FormatString, Arguments)
|
%% format(Stream, FormatString, Arguments)
|
||||||
%
|
%
|
||||||
@@ -461,9 +463,11 @@ format(Fs, Args) :-
|
|||||||
% binary stream, then the code of each emitted character must be in
|
% binary stream, then the code of each emitted character must be in
|
||||||
% 0..255.
|
% 0..255.
|
||||||
|
|
||||||
format(Stream, Fs, Args) :-
|
format(_, _, _) :- not_used.
|
||||||
phrase_to_stream(format_(Fs, Args), Stream),
|
|
||||||
flush_output(Stream).
|
user:goal_expansion(format(Stream, Fs, Args),
|
||||||
|
( pio:phrase_to_stream(format:format_(Fs, Args), Stream),
|
||||||
|
flush_output(Stream))).
|
||||||
|
|
||||||
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
?- phrase(format:cells("hello", [], 0, [], []), Cs).
|
?- phrase(format:cells("hello", [], 0, [], []), Cs).
|
||||||
|
|||||||
Reference in New Issue
Block a user