トップ «前の日記(2008-03-15) 最新 次の日記(2008-03-27)» 編集

Route 477



2008-03-21

[arc][scheme] ArcとSchemeのI/Oを比べてみる

ArcのI/O関数のまとめページがあったので,Schemeの関数名と比較してみた.

全体的に,かなりゴルフされています(笑).Schemeは長くても明確な名前を選ぶので尚更.

昔はSchemeの関数名は長すぎると思ってたんですが,最近は上手に抽象化すれば気にならないのかなぁと思ったりしてます.

Input

ArcScheme(Gauche)
readb-
readcread-char
peekcpeek-char
readlineget-line
sreadread
read- (read+read-from-string)
readstring- (read-from-string)
saferead-
readall-
loadload

Output

ArcScheme(Gauche)
dispdisplay
writewrite
writeb-
writecwrite-char
pr- (for-each+display)
prn- (for-each+display+newline)
prall- (display+string-join)
prs- (print)
prf- (print+format)
parse-formatformat
ero-
warn-

File I/O

ArcScheme(Gauche)
readfile- (port-map+read+with-input-from-file)
readfile1- (read+with-input-from-file)
writefile1- (write+with-output-to-file)
infileopen-input-file
w/infilecall-with-input-file
outfileopen-output-file
w/outfilecall-with-output-file
w/appendfilewith-output-to-file
closeclose-input-port, close-output-port
pipe-from- (with-input-from-prosess)

stdin, stdout, and stderr

ArcScheme(Gauche)
stdinstandard-input-port
stdoutstandard-output-port
stderrstandard-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

ArcScheme(Gauche)
instringopen-string-input-port (open-input-string)
w/instring-
fromstring- (with-input-from-string)
outstringopen-output-string-port (open-output-string)
inside- (get-output-string)
w/outstring-
tostring- (with-output-to-string)