How to initialize a string with a fill pointer in Common Lisp?
adjustable-array, common-lisp, fill-pointer, format, string
Solution
`(make-array 0 :element-type 'character :fill-pointer 0)` is the canonical way (well, it's quite possible to use an initial non-zero length and use `:initial-contents` with a string value). It's also possible to specify the fil-pointer value as `t`, that will set the fill-pointer at the end of the string.
Problem
I want to use formatted output in a loop to generate a string. Manual says it can be easily done by giving `format` function a string with a fill pointer as a destination. Unfortunately, it is not transparent from the manual how to initialize this string in the first place. I tried `(string "")` and `(format nil "")` with no luck. `(make-array 0 :element-type 'character :fill-pointer 0)` did work for me, but it just doesn't feel right. What is the proper way to initialize a string with a fill pointer?