On Feb 18, 2013 11:21 AM, "Alex Young" <alex@blackkettle.org> wrote:

> I've got a C function behind a c-lambda which needs to do some grubbing
> around with a select(2) call and decide on a scheme symbol to return as
> an indication of what it did, and whether an error condition occurred.
> Basically I want to use that symbol as a signal to drive a transition in
> a state machine.
>
> How one gets hold of a named symbol as a ___SCMOBJ (or anything more
> appropriate) from C isn't explained in the docs, and the wiki seems to
> have fallen over. It's also not immediately obvious from gambit.h
> whether there's a macro for this purpose.
>

I think there are a couple of ways you can do this:

1) c-define a Scheme procedure that returns the symbols you're interested in based on some parameter. In the most general case it could be just a wrapper around string->symbol.

2) you're returning symbols so I think you want your C function to return to Scheme. Have your C function return a result code and wrap it in a Scheme procedure that maps the result code onto a symbol. You can look at Gamsock on the dumping ground for examples of how to wrap a low-level C function in a Scheme procedure that handles the Scheme objects.