2008-03-21
■ [arc][scheme] ArcとSchemeのI/Oを比べてみる
ArcのI/O関数のまとめページがあったので,Schemeの関数名と比較してみた.
全体的に,かなりゴルフされています(笑).Schemeは長くても明確な名前を選ぶので尚更.
昔はSchemeの関数名は長すぎると思ってたんですが,最近は上手に抽象化すれば気にならないのかなぁと思ったりしてます.
Input
Arc | Scheme(Gauche) |
---|---|
readb | - |
readc | read-char |
peekc | peek-char |
readline | get-line |
sread | read |
read | - (read+read-from-string) |
readstring | - (read-from-string) |
saferead | - |
readall | - |
load | load |
Output
Arc | Scheme(Gauche) |
---|---|
disp | display |
write | write |
writeb | - |
writec | write-char |
pr | - (for-each+display) |
prn | - (for-each+display+newline) |
prall | - (display+string-join) |
prs | - (print) |
prf | - (print+format) |
parse-format | format |
ero | - |
warn | - |
File I/O
Arc | Scheme(Gauche) |
---|---|
readfile | - (port-map+read+with-input-from-file) |
readfile1 | - (read+with-input-from-file) |
writefile1 | - (write+with-output-to-file) |
infile | open-input-file |
w/infile | call-with-input-file |
outfile | open-output-file |
w/outfile | call-with-output-file |
w/appendfile | with-output-to-file |
close | close-input-port, close-output-port |
pipe-from | - (with-input-from-prosess) |
stdin, stdout, and stderr
Arc | Scheme(Gauche) |
---|---|
stdin | standard-input-port |
stdout | standard-output-port |
stderr | standard-error-port |
call-w/stdin | - (call-with-input-port) |
w/stdin | - (with-input-from-port) |
call-w/stdout | - (call-with-output-port) |
w/stdout | - (with-output-to-port) |
String Port I/O
Arc | Scheme(Gauche) |
---|---|
instring | open-string-input-port (open-input-string) |
w/instring | - |
fromstring | - (with-input-from-string) |
outstring | open-output-string-port (open-output-string) |
inside | - (get-output-string) |
w/outstring | - |
tostring | - (with-output-to-string) |