[gambit-list] Returning a symbol to scheme from C

Mikael mikael.rcv at gmail.com
Tue Feb 19 06:03:49 EST 2013

Well, if you think about it, this is what Gambit does internally - in a
sexp  the symbol abcde is wrapped internally to (string->symbol "abcde").

In the C world, you could make a string->symbol wrapper so you'd get

___SCMOBJ alex_sy1 = string_to_symbol("alex_sy1");


With some C macro magic, perhaps that could even be written as


or something.

(Also, have a look at string->symbol's definition, imaginably a lot of it
is written in C in such a way that you could just call it directly from C,
well, that might more probably not be an option too.)

2013/2/19 Alex Young <alex at blackkettle.org>

> > 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.
> >
> Yeah, I was trying to avoid having to do this.  I'd be defining the
> return codes twice - once as ints (or whatever) and once as symbols.  I
> guess that's all macroable away, but still... not particularly elegant.
> Thanks for the suggestions :-)
> --
> Alex
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20130219/a8125cdb/attachment.htm>

More information about the Gambit-list mailing list