> On Fri, 9 Jun 2017 10:17:18 +0200 > Catonano <caton...@gmail.com> wrote: > > > If you want to manipulate a scheme bytevector at the C level you can > also look at the c-write procedure here for ideas: > https://github.com/ChrisVine/guile-a-sync/blob/master/lib/unix_write. > c > > (As a point of detail, this procedure is only required with guile-2.0 > - > with guile-2.2, suspendable ports are used instead - but it shows you > one approach to working with scheme buffers or other objects.)
When I scheme in C (lol, sounds funny), I ended up with bytevector code like this: size_t len = scm_c_bytevector_length (bv); signed char * SCM_BYTEVECTOR_CONTENTS (bv); Now, I'm pretty new at this, so the reason I'm asking it to seek opinions on a best practice re: this thread. The reason I write it that way is that, I think, the scm_c_bytevector_length will throw an exception if it's not a bytevector. This lets me be a bit lazy and not explicitly check. Then I get the pointer to the bv. This could just be a case of there-are-many-ways-to-do-it, but I would have not thought to do: void* c_buf = scm_to_pointer(scm_bytevector_to_pointer(bv, begin)); per that example so I was curious if there was an advantage or something wrong with my thinking of how I Scheme in C :) I'm using Guile 2.0.11 on Ubuntu. Josh