Node:General Conversion, Next:, Previous:Copying, Up:Utility Functions

24.5 General String Conversion

When debugging Scheme programs, but also for providing a human-friendly interface, a procedure for converting any Scheme object into string format is very useful. Conversion from/to strings can of course be done with specialized procedures when the data type of the object to convert is known, but with this procedure, it is often more comfortable.

object->string converts an object by using a print procedure for writing to a string port, and then returning the resulting string. Converting an object back from the string is only possible if the object type has a read syntax and the read syntax is preserved by the printing procedure.

object->string obj [printer] Scheme Procedure
scm_object_to_string (obj, printer) C Function
Return a Scheme string obtained by printing obj. Printing function can be specified by the optional second argument printer (default: write).