seanjensengrey / mosh-scheme

Automatically exported from code.google.com/p/mosh-scheme
Other
0 stars 0 forks source link

setting position to zero on bytevector input port raises error #200

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Run the program:

(import (rnrs))
(define port (open-bytevector-input-port '#vu8()))
(set-port-position! port 0)

What is the expected output? What do you see instead?
It should work.  It raises an "invalid port position" error.

What version of the product are you using? On what operating system?
Mosh R6RS scheme interpreter, version 0.2.7 (revision master 2011/03/27 
11:05:18 mosh-0.2.5-557-g7beb76c).  i686-pc-linux-gnu.

Please provide any additional information below.
Other implementations (with the exception of Guile) accept this.  I have 
discovered it in my actual code, so there is at least one case in which this is 
useful.  A rationale that I consider valid for accepting zero as port position 
is that it should be possible to set the position to every value returned by 
PORT-POSITION, that is the following should not fail:

(import (rnrs))
(define port (open-bytevector-input-port '#vu8()))
(set-port-position! port (port-position port))

Original issue reported on code.google.com by mrc....@gmail.com on 31 Mar 2011 at 9:21

GoogleCodeExporter commented 9 years ago
Agreed and fixed.

Original comment by hige...@gmail.com on 31 Mar 2011 at 11:36

GoogleCodeExporter commented 9 years ago
Fixed with position zero, but now the following program fails (all the other 
implementation accept it, but Guile):

#!r6rs
(import (rnrs))

(define port (open-bytevector-input-port '#vu8(1 2 3)))

(write (port-position port))(newline)
(get-u8 port)
(write (port-position port))(newline)
(get-u8 port)
(write (port-position port))(newline)
(get-u8 port)
(write (port-position port))(newline)

(set-port-position! port (port-position port))

Original comment by mrc....@gmail.com on 7 Apr 2011 at 7:36

GoogleCodeExporter commented 9 years ago
Fixed. Thank you!

Original comment by hige...@gmail.com on 7 Apr 2011 at 8:32