Derick Eddington
2009-03-19 05:25:09 UTC
Closing string input ports or string output ports changes them from
textual to binary and they are no longer considered input or output
ports. Ikarus, PLT, and Ypsilon don't do this. I'm not sure what R6RS
requires about this, but this is unexpected and could cause serious
confusion.
I made a portable test program to check ports' state as they change from
initial to EOF to closed. It's attached, and below is its current
failing output. I only tested string input and output ports, but the
program is made to easily add more tests for all the different ways of
making various types of ports.
[***@eep:~/t10]-> larceny -r6rs -program ports-state-tests.sps
--------------------------------------------------
Initial: string-input-port := (open-string-input-port "blah")
--------------------------------------------------
(port? string-input-port) => #t ; correct
(textual-port? string-input-port) => #t ; correct
(binary-port? string-input-port) => #f ; correct
(input-port? string-input-port) => #t ; correct
(output-port? string-input-port) => #f ; correct
(port-eof? string-input-port) => #f ; correct
--------------------------------------------------
EOF: string-input-port
--------------------------------------------------
(port? string-input-port) => #t ; correct
(textual-port? string-input-port) => #t ; correct
(binary-port? string-input-port) => #f ; correct
(input-port? string-input-port) => #t ; correct
(output-port? string-input-port) => #f ; correct
(port-eof? string-input-port) => #t ; correct
(port-transcoder string-input-port) => 64 ; correct
(port-has-port-position? string-input-port) => #t ; correct
(port-has-set-port-position!? string-input-port) => #t ; correct
--------------------------------------------------
Closed: string-input-port
--------------------------------------------------
(port? string-input-port) => #t ; correct
(textual-port? string-input-port) => #f ; *** failed ***
; expected result: #t
(binary-port? string-input-port) => #t ; *** failed ***
; expected result: #f
(input-port? string-input-port) => #f ; *** failed ***
; expected result: #t
(output-port? string-input-port) => #f ; correct
(port-transcoder string-input-port) => 64 ; correct
(port-has-port-position? string-input-port) => #t ; correct
(port-has-set-port-position!? string-input-port) => #t ; correct
--------------------------------------------------
Initial: string-output-port := (let-values (((sop get) (open-string-output-port))) sop)
--------------------------------------------------
(port? string-output-port) => #t ; correct
(textual-port? string-output-port) => #t ; correct
(binary-port? string-output-port) => #f ; correct
(input-port? string-output-port) => #f ; correct
(output-port? string-output-port) => #t ; correct
--------------------------------------------------
Closed: string-output-port
--------------------------------------------------
(port? string-output-port) => #t ; correct
(textual-port? string-output-port) => #f ; *** failed ***
; expected result: #t
(binary-port? string-output-port) => #t ; *** failed ***
; expected result: #f
(input-port? string-output-port) => #f ; correct
(output-port? string-output-port) => #f ; *** failed ***
; expected result: #t
(port-transcoder string-output-port) => 64 ; correct
(port-has-port-position? string-output-port) => #t ; correct
(port-has-set-port-position!? string-output-port) => #t ; correct
; *** checks *** : 30 correct, 6 failed. First failed example:
(textual-port? string-input-port) => #f ; *** failed ***
; expected result: #t
[***@eep:~/t10]->
textual to binary and they are no longer considered input or output
ports. Ikarus, PLT, and Ypsilon don't do this. I'm not sure what R6RS
requires about this, but this is unexpected and could cause serious
confusion.
I made a portable test program to check ports' state as they change from
initial to EOF to closed. It's attached, and below is its current
failing output. I only tested string input and output ports, but the
program is made to easily add more tests for all the different ways of
making various types of ports.
[***@eep:~/t10]-> larceny -r6rs -program ports-state-tests.sps
--------------------------------------------------
Initial: string-input-port := (open-string-input-port "blah")
--------------------------------------------------
(port? string-input-port) => #t ; correct
(textual-port? string-input-port) => #t ; correct
(binary-port? string-input-port) => #f ; correct
(input-port? string-input-port) => #t ; correct
(output-port? string-input-port) => #f ; correct
(port-eof? string-input-port) => #f ; correct
--------------------------------------------------
EOF: string-input-port
--------------------------------------------------
(port? string-input-port) => #t ; correct
(textual-port? string-input-port) => #t ; correct
(binary-port? string-input-port) => #f ; correct
(input-port? string-input-port) => #t ; correct
(output-port? string-input-port) => #f ; correct
(port-eof? string-input-port) => #t ; correct
(port-transcoder string-input-port) => 64 ; correct
(port-has-port-position? string-input-port) => #t ; correct
(port-has-set-port-position!? string-input-port) => #t ; correct
--------------------------------------------------
Closed: string-input-port
--------------------------------------------------
(port? string-input-port) => #t ; correct
(textual-port? string-input-port) => #f ; *** failed ***
; expected result: #t
(binary-port? string-input-port) => #t ; *** failed ***
; expected result: #f
(input-port? string-input-port) => #f ; *** failed ***
; expected result: #t
(output-port? string-input-port) => #f ; correct
(port-transcoder string-input-port) => 64 ; correct
(port-has-port-position? string-input-port) => #t ; correct
(port-has-set-port-position!? string-input-port) => #t ; correct
--------------------------------------------------
Initial: string-output-port := (let-values (((sop get) (open-string-output-port))) sop)
--------------------------------------------------
(port? string-output-port) => #t ; correct
(textual-port? string-output-port) => #t ; correct
(binary-port? string-output-port) => #f ; correct
(input-port? string-output-port) => #f ; correct
(output-port? string-output-port) => #t ; correct
--------------------------------------------------
Closed: string-output-port
--------------------------------------------------
(port? string-output-port) => #t ; correct
(textual-port? string-output-port) => #f ; *** failed ***
; expected result: #t
(binary-port? string-output-port) => #t ; *** failed ***
; expected result: #f
(input-port? string-output-port) => #f ; correct
(output-port? string-output-port) => #f ; *** failed ***
; expected result: #t
(port-transcoder string-output-port) => 64 ; correct
(port-has-port-position? string-output-port) => #t ; correct
(port-has-set-port-position!? string-output-port) => #t ; correct
; *** checks *** : 30 correct, 6 failed. First failed example:
(textual-port? string-input-port) => #f ; *** failed ***
; expected result: #t
[***@eep:~/t10]->
--
: Derick
----------------------------------------------------------------
: Derick
----------------------------------------------------------------