mit-scheme-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MIT-Scheme-devel] [RFC] Patch for SRFI-4


From: craven
Subject: [MIT-Scheme-devel] [RFC] Patch for SRFI-4
Date: Fri, 18 Mar 2016 14:23:45 +0100
User-agent: Notmuch/0.21 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-unknown-linux-gnu)

Hello fellow Schemers!

I have locally implemented and used srfi-4 (Homogeneous numeric vector
datatypes) and have attached a patch against git HEAD here.

All the different vector types of srfi-4 are subsumed in a new type
TC_INTVEC (which replaces the commented-out TC_COMBINATION_1 0x07, but
could use any other code). The first byte contains the element size in
bytes and the signedness, after that all the indexed elements follow.

The following new primitives are implemented:

(integer-vector-cons length element-size-in-bytes signedness)
(integer-vector-type intvec)
(integer-vector-ref intvec index element-size-in-bytes signedness)
(integer-vector-set! intvec index value element-size-in-bytes)
(integer-vector-length intvec element-size-in-bytes)
(integer-vector? intvec)

These are exposed as intvec-...

A new package (runtime srfi-4) implements all of srfi-4 with the
following exceptions:

- The f32/f64 functions all map to the respective flo:vector..
  functions.
- Neither parse nor unparse is implemented for f32/f64.

The test suite code is taken from guile Scheme, if that is impossible
due to licensing problems, I could provide newly-written code.

This functionality is very useful for the FFI, especially with things
like OpenGL, as it allows to populate the relevant data arrays directly
from Scheme.

I'd be glad about any comments on whether this would be acceptable for
inclusion in MIT/GNU Scheme proper. I'll update and change the code if
you have any suggestions for that. I'd also update the documentation. It
might be useful to extend this for f32/f64 too (converting an f32 to a
normal boxed double when it is accessed) to implement all of srfi-4.

Thank you for any comments and suggestions,

Peter

Attachment: intvec.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]