Stream may be a physical stream number or a reserved or user-defined symbolic stream name.
If Stream is an opened input stream, its content is read and compiled as in compile/1. The compilation stops at the stream end, but the stream remains open.
Success:
[eclipse]: open(X, string(25), s).
X = ""
yes.
[eclipse]: writeln(s, "q(X) :- write(X)."), at(s,P).
P = 18
yes.
[eclipse]: compile_stream(s), % pointer must be at
> q(hi). % the start of the file.
string compiled 0 bytes in 0.00 seconds
calling an undefined procedure q(hi) in module eclipse
[eclipse]: seek(s,0), compile_stream(s).
string compiled 96 bytes in 0.05 seconds
yes.
[eclipse]: q(hi).
hi
yes.
[eclipse]: seek(s,18), write(s, " b.").
yes.
[eclipse]: seek(s,0), compile_stream(s).
string compiled 124 bytes in 0.05 seconds
yes.
[eclipse]: q(hi).
hi
yes.
[eclipse]: b.
yes.
[eclipse]: [user].
compile_term(Term) :-
open(_, string, s),
write(s,Term),
write(s, " .\n"),
seek(s,0),
compile_stream(s),
close(s).
user compiled 380 bytes in 0.02 seconds
yes.
[eclipse]: compile_term(g(X) :- writeln(X)).
string compiled 56 bytes in 0.00 seconds
X = _g60
yes.
[eclipse]: g(hi).
hi
yes.
Error:
compile_stream(X). (Error 4).
compile_stream(1.0). (Error 5).
compile_stream(1). (Error 192).
compile_stream(2). (Error 192).
compile_stream(20). (Error 192).
compile_stream(a). (Error 193).