This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Westley A Sherman <wsherman@umich.edu> writes: > char * scm2string(SCM object) { > SCM stringify; > char * string; > > stringify = gh_eval_str("(lambda(object)" > " (with-output-to-string" > " (lambda() (write object))))"); > > string = gh_scm2newstr(gh_call1(stringify, object), 0); > > return string; > } If you're concerned about speed, you can generate 'stringify' just once, and then reference it repeatedly, as long as you scm_protect_obj() it. Other than that, your code seems OK to me. It seems like a bit of a waste to have to copy the string just to eval it in string2scm. If you're concerned about speed I bet you can cook something up that avoids the expensive malloc(). -russ -- IDIOT, n - A member of a large and powerful tribe whose influence in human affairs has always been dominant and controlling. -- Ambrose Bierce