[gambit-list] read-subu8vector

Marc Feeley feeley at iro.umontreal.ca
Thu Feb 21 17:59:55 EST 2008


On 21-Feb-08, at 4:51 PM, Jeremie Lasalle Ratelle wrote:

> > (define vect (make-u8vector 3))
> > (call-with-input-string "string" (lambda (pt) (read-subu8vector  
> vect 0 2 pt)))
>
> *** ERROR IN call-with-input-string -- Input port character buffer  
> is not empty
> (read-subu8vector '#u8(0 0 0) 0 1 '#<input-port #2 (string)>)
>
> read-subu8vector calls macro-lock-and-check-input-port-character- 
> buffer-empty
> I guess it's a bug since I don't see what would be the use. Or  
> enlighten me...


The error message is wrong (now fixed on the repository).  You should  
have gotten:

 > (define vect (make-u8vector 3))
 > (call-with-input-string "string" (lambda (pt) (read-subu8vector  
vect 0 2 pt)))
*** ERROR IN call-with-input-string -- (Argument 4) Byte INPUT PORT  
expected
(read-subu8vector '#u8(0 0 0) 0 2 '#<input-port #2 (string)>)

The correct thing to do is to read from a byte port, for example a  
u8vector port:

 > (call-with-input-u8vector '#u8(48 49 50 51) (lambda (pt) (read- 
subu8vector vect 0 2 pt)))
2
 > vect
#u8(48 49 0)

Marc




More information about the Gambit-list mailing list