unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* bytestructures 2.0.0
@ 2022-02-20 19:51 Taylan Kammer
  2022-02-20 23:25 ` Matt Wette
  0 siblings, 1 reply; 5+ messages in thread
From: Taylan Kammer @ 2022-02-20 19:51 UTC (permalink / raw)
  To: Guile User

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



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-02-23 21:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-20 19:51 bytestructures 2.0.0 Taylan Kammer
2022-02-20 23:25 ` Matt Wette
2022-02-21 21:09   ` Taylan Kammer
2022-02-22 20:50     ` bytestructures 2.0.1 Taylan Kammer
2022-02-23 21:36       ` Jérémy Korwin-Zmijowski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).