Next: , Previous: Bytevectors as Strings, Up: Bytevectors


6.6.6.7 Accessing Bytevectors with the Generalized Vector API

As an extension to the R6RS, Guile allows bytevectors to be manipulated with the generalized vector procedures (see Generalized Vectors). This also allows bytevectors to be accessed using the generic array procedures (see Array Procedures). When using these APIs, bytes are accessed one at a time as 8-bit unsigned integers:

     (define bv #vu8(0 1 2 3))
     
     (generalized-vector? bv)
     ⇒ #t
     
     (generalized-vector-ref bv 2)
     ⇒ 2
     
     (generalized-vector-set! bv 2 77)
     (array-ref bv 2)
     ⇒ 77
     
     (array-type bv)
     ⇒ vu8