Skip to content

Commit 8558bd2

Browse files
authored
Merge pull request #2874 from triska/read_from_chars_instantiated
generalize read_from_chars/2 and read_term_from_chars/3 to allow instantiated Term
2 parents 20525e5 + ba9fed3 commit 8558bd2

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lib/charsio.pl

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@
195195
; type_error(in_character, C, get_single_char/1)
196196
).
197197

198-
%% read_from_chars(+Chars, -Term).
198+
%% read_from_chars(+Chars, ?Term).
199199
%
200200
% Given a string made of chars which contains a representation of
201201
% a Prolog term, Term is the Prolog term represented. Example:
@@ -206,10 +206,10 @@
206206
% ```
207207
read_from_chars(Chars, Term) :-
208208
must_be(chars, Chars),
209-
must_be(var, Term),
210-
'$read_from_chars'(Chars, Term).
209+
'$read_from_chars'(Chars, Term0),
210+
Term = Term0.
211211

212-
%% read_term_from_chars(+Chars, -Term, +Options).
212+
%% read_term_from_chars(+Chars, ?Term, +Options).
213213
%
214214
% Like `read_from_chars`, except the reader is configured according to
215215
% `Options` which are those of `read_term`.
@@ -220,9 +220,9 @@
220220
% ```
221221
read_term_from_chars(Chars, Term, Options) :-
222222
must_be(chars, Chars),
223-
must_be(var, Term),
224223
builtins:parse_read_term_options(Options, [Singletons, VariableNames, Variables], read_term_from_chars/3),
225-
'$read_term_from_chars'(Chars, Term, Singletons, Variables, VariableNames).
224+
'$read_term_from_chars'(Chars, Term0, Singletons, Variables, VariableNames),
225+
Term = Term0.
226226

227227
%% write_term_to_chars(+Term, +Options, -Chars).
228228
%

0 commit comments

Comments
 (0)