On 2013-09-18, at 2:16 AM, Vijay Mathew vijay.the.lisper@gmail.com wrote:
What is the correct way to generate symbols in C code? What is the difference between DEF_SYM1 and DEF_SYM2 macros?
Calls to DEF_SYM1 and DEF_SYM2 are generated by the Gambit compiler and aren't meant to be used directly. They must respect some invariants and refer to other tables in a way that is difficult for a human to respect. DEF_SYM1 is used for creating symbols in a dynamic way, and DEF_SYM2 is used for creating symbols in a static way.
Do you really need to create fresh symbols from C code, or do you want to refer from C code to symbols that are defined in the Scheme code? If the later, you simply refer to the macro whose name is the (mangled) symbol's name prefixed with ___SYM_ . So to access the symbol foobar, refer to ___SYM_foobar. To access the symbol foo-bar, refer to ___SYM_foo_2d_bar. It is similar to access Scheme global variables from C. Just use the ___GLO_ prefix.
Marc