[gambit-list] Output Vector Ports

vasil vasil.s.d at gmail.com
Tue Mar 31 15:46:09 EDT 2009


On Linux:

> (with-output-to-u8vector (make-u8vector 0) (lambda () (write-u8 2)
(write-u8 5)))
#u8(2 5)

On Windows:
> (with-output-to-u8vector (make-u8vector 0) (lambda () (write-u8 2)
(write-u8 5
)))
#u8(2 5)

with-output-to-u8vector CREATES a new u8-vector, it is not destructive!
so do like this:

>(let ((s (make-u8vector 3 0)))
   (set! s (with-output-to-u8vector s (lambda ()
      (write-u8 65)
      (write-u8 45)
      (force-output))))
   s)
#u8(0 0 0 65 45)
>


> Hi All,
> 
> I'm sure I'm doing something stupid here, but I just can't get output 
> vector ports to work. I've tried these two examples but get the same 
> result :-
> 
> (let ((s (make-u8vector 3 0)))
>   (with-output-to-u8vector s (lambda ()
>      (write-u8 65)
>      (write-u8 45)
>      (force-output)))
>   s)
> 
> => #u8(0 0 0)
> 
> (*let* ((s (make-u8vector 3 0)))
>   (*let* ((p (open-u8vector s)))
>      (write-u8 65 p)
>      (write-u8 45 p)
>      (close-output-port p)
>      )
>   s)
> 
> => #u8(0 0 0)
> 
> I can get input ports working fine i.e. I can read from a port from the 
> vectors but the writes seem to completely fail to update the vector. Am 
> I doing something wrong, or is there a bug in Gambit ? I'm using 4.4.2 
> on Windows.
> 
> Thanks
> 
> Andrew
> 
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
> 




More information about the Gambit-list mailing list