I'd like to announce the release of bytestructures 2.0.0 for Scheme and Guile in particular.
Don't be fooled by the major version bump, there's nothing radically new in this release. :-) https://github.com/TaylanUB/scheme-bytestructures What's new? ----------- This release bumps the major version number since there is one API-breaking change: The indexing semantics of bs:pointer (Guile-specific) have changed from allowing an arbitrary index to implicitly deref the pointer, to allowing only an integer index (besides the symbol '*') to deref with an offset akin to "pointer + offset" in C. Other news in this release: - There is now support for anonymous unions within struct definitions. - The macro API now allows you to define two additional macros via its macro-defining-macro define-bytestructure-accessors. The new generated macros allow you to provide an initial offset into a bytevector when getting or setting values. See relevant sections of the README for detailed documentation. What's bytestructures anyway? ----------------------------- The library offers a system imitating the type system of the C programming language, to be used on bytevectors. C's type system works on raw memory, and ours works on bytevectors which are an abstraction over raw memory in Scheme. The system is in fact more powerful than the C type system, elevating types to first-class status. A C type corresponds to a "bytestructure descriptor" object in our system. ;; typedef uint8_t uint8_v3_t[3]; (define uint8-v3 (bs:vector 3 uint8)) ;; typedef struct { uint16_t x; uint8_v3_t y; } my_struct_t; (define my-struct (bs:struct `((x ,uint16) (y ,uint8-v3)))) These can then be bundled with a bytevector, yielding a "bytestructure" object on which referencing and assignment work in accordance with the types declared in the descriptor. ;; my_struct_t str; (define str (bytestructure my-struct)) ;; my_struct_t str = { 0, 1 }; (define str (bytestructure my-struct #(0 1))) ;; str.y[2] (bytestructure-ref str 'y 2) ;; str.y[2] = 42; (bytestructure-set! str 'y 2 42) If your Scheme implementation supports syntax-case, then a macro-based API is available as well, for when the procedural API is too slow. Full documentation here: https://github.com/TaylanUB/scheme-bytestructures (Apologies for still using GitHub.) -- Taylan