On Sun, 2011-09-18 at 17:30 +0200, Thien-Thi Nguyen wrote: > The double-quote stripping is kind of hacky. I would create a port > and ‘display’ the result of ‘scm_c_eval_string’ to it.
Thanks for the hints. I've reworked my code to implement a generic "SCM to make string" function; currently it looks like this: char * cvt_scm_to_str (SCM obj) { char *str; if (scm_is_bool (obj) && scm_is_true (obj)) str = xstrdup ("t"); else if (scm_is_number (obj) || scm_is_string (obj) || scm_is_symbol (obj)) { SCM port = scm_open_output_string (); scm_display (obj, port); str = scm_to_locale_string (scm_get_output_string (port)); scm_close_output_port (port); } else str = xstrdup (""); return str; } That's better than what I had before, but I still have some concerns. For example, what if a Guile call wanted to return a list? I can use display as above, but the list will be enclosed in parentheses, which is not how make displays lists. Is there a clean way to handle this? I could write a function then invoke it with scm_map() (right?) but this seems like it might be work. Also what if the data structure is more complex, where some elements of the list are lists themselves, etc.? I can "flatten" the entire thing out, I suppose. Or I could ignore them as above and require the Guile scripting to convert the list into a string before returning it. -- ------------------------------------------------------------------------------- Paul D. Smith <psm...@gnu.org> Find some GNU make tips at: http://www.gnu.org http://make.mad-scientist.net "Please remain calm...I may be mad, but I am a professional." --Mad Scientist