[gambit-list] creating homogeneous vectors from the FFI

Marc Feeley feeley at iro.umontreal.ca
Sat Jan 12 22:37:22 EST 2008


On 12-Jan-08, at 8:07 PM, David Rush wrote:

> Hi there,
>
> I am slowly getting code for FCGI support running, but I have a small
> issue with keeping Gambit compatibility - it is unclear to me how to
> create a u8vector to bring the output of read() back into the Scheme
> world.

If all you need is to interface to read(), why don't you use read- 
subu8vector?  For example:

(define v (make-u8vector 20 0))
(define n (read-subu8vector v 5 8)) ;; here we type: ab <enter>
(pp n) ;; prints: 3
(pp v) ;; prints: #u8(0 0 0 0 0 97 98 10 0 0 0 0 0 0 0 0 0 0 0 0)

That way you don't even need to code in C!

Marc




More information about the Gambit-list mailing list