Closed APIPLM closed 1 year ago
The output-port and input-port might be different, the above refer to input-port.
Thanks! Added in commit cde06a6 and published at https://docs.scheme.org/surveys/read-line/. Sorry about the long delay.
Thanks for the updated. And read-line is a part of the read-string in Lisp and Scheme or part of the read-line of the C function read-line for input-file port. Mostly depend on the implementer in such surroundings, no way to work out for me. Like the people living the way used to be for a long time, it is a hard change.@Sayward
Withdraw the part of input file port in this survey. Sorry. I did not verify the input for the input foo.txt
file before running the (read-line (open-input-file "foo.txt"))
line in each implementation.
I mean that echo "foo\rbar" >foo.txt
on the docker container(Racket Gauche Chibi Mit Gambit Implementation)
which the images are from https://hub.docker.com/u/schemers has an issue, which is that cat foo.txt
command does not get the foo\rbar
content, rather than the bar content.
For Chicken implementation, it run on the my VM machine, which does not have an issue about echo "foo\rbar" command, and the output of cat foo.txt
is foo\rbar
After I create the input file foo.txt
by tee foo\rbar foo.txt
in the each container, now that for all the above mentioned implementation for running (read-line (open-input-file "foo.txt"))
in REPL, and the output is "foo\rbar". except the Kawa implementation
, the output is foo\rbar
.
Run the below two lines in REPL. The content of
foo.txt
file isfoo\rbar
(read-line (open-input-file "foo.txt"))
(read-line (open-input-string "foo\rbar"))
Racket | gauche | Chibi |Chicken | Mit-scheme | Gambit | Kawa "foo\rbar" | "foo" |"foo\rbar" | "foo\\rbar" | ;Value: "foo\rbar" | "foo\rbar" | foo "foo\rbar" | "foo" |"foo" | "foo" | ;Value: "foo\rbar" | "foo\rbar" | foo
When looking into the source code of the different implementation, Like in Mit-scheme, in the
./src/runtime/textual-port.scm
f file, it wrapped the string-port and file-port as the new record<textual-port-type>
. so when usingread-line,
it has the same interface to be invoked. Then it be handled in the different way. But in Chibi and Chicken, there is not such wrapped.read-line
directly treat string-port and file-port differently. That is why the output are different.Surprised in ChezScheme, Seem like it does not have
read-line
procedure.