[gambit-list] Returning a symbol to scheme from C
Alex Young
alex at blackkettle.org
Mon Feb 18 10:41:42 EST 2013
Hi there,
I asked this question over on StackOverflow yesterday, but it's not had
any joy so far.
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've tried doing this:
(define (foo) 'bar)
and taking a look at the C it generates, but it looks to me like
following this pattern only works if you know the offset into the symbol
table in advance.
Is this possible out of the box? My workaround at the moment is to pass
in returnable symbols as arguments to the function, but with a larger
set of symbols I want to be able to return, that's going to get very
unwieldy very quickly.
Thanks,
--
Alex
More information about the Gambit-list
mailing list