[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

write-to-string



At  7:08 PM 5/26/93 -0400, kevin@freya.cs.umass.edu wrote:
>WRITE-TO-STRING takes a number of keyword arguments (e.g., :escape)
>that control the printed representation of the objects output to the
>string.  These all default to the corresponding global control
>variables (e.g., *print-escape*).  Because you didn't specify the
>:escape keyword, in your call to write-to-string, it's output will
>change depending on the value of *print-escape*.
>
>You should do the following instead:
>
>  (with-standard-io-syntax
>    (write-to-string ...))
>
>This  will ensure that strings are printed with double quotes, numbers
>are printed in base 10, etc.

Slightly faster than the code above, and with exactly the same effect as
(format nil "~s" x) is:

(prin1-to-string x)

prin1-to-string binds *print-escape* true, write-to-string doesn't.