Symbols don't gc by default and they don't move, so their ___SCMOBJ representations remain constant across GC:s.
Does this solve your problem? (of course you modify get-sy to not be a function of an input argument but to perform your desired function and return the symbol return value based on the result reached.)
(c-declare "___SCMOBJ alex_symbols[123];") (define upload-sy! (c-lambda (int scheme-object) void "alex_symbols[___arg1] = ___arg2;")) (define get-sy (c-lambda (int) scheme-object "___result = alex_symbols[___arg1];"))
Mikael
2013/2/18 Alex Young alex@blackkettle.org
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 _______________________________________________ Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list