Didn't find a guide to this in the wiki, mailing list archives, gambit.h
comments or the examples directory that comes with Gambit. How do you
build a Scheme list, vector, etc. in C and then return it to Scheme?
As a simple exercise to learn the FFI, I started by wrapping Unix
uname(). That function fills a struct with a few null-terminated
strings. It was easy to figure out how to return an individual string
from C to Scheme but I'm stumped trying to return many of them at once
in a list or a vector (or as multiple values).
I imagine this is done by calling the C constructors for the desired
Scheme data types but I couldn't find those in <gambit.h>. There's
___BEGIN_ALLOC_VECTOR and ___END_ALLOC_VECTOR but I couldn't get those
to work. Also ___make_vector but it takes some kind of
___processor_state argument. That and the lowercase name make it seem
like an internal function that I shouldn't use.
If someone has the time to write a brief guide on constructing and
returning lists/vectors/multiple values in C, it could be useful to
others as well.