The result varies by Common Lisp implementation:
CCL | "w" |
CLISP | "w" |
ACL | "w" |
ECL | "w" |
MKCL | "w" |
Clasp | "w" |
npt | "w" |
ABCL | "woo" |
SBCL | "woo" |
LispWorks | "woo" |
Corman | "foow" |
So for a few implementations, the output is truncated by the use of file-position (as if by setting the fill-pointer). SBCL's implementation (since version 0.8.3.77) remembers the ending position and doesn't truncate the output. Which is less surprising, unless you actually wanted to truncate the output. Then you'd need a different approach. LispWorks appears to be in the same camp with SBCL. In Corman Common Lisp, the file-position is different from the actual output position.
Clozure CL
Since file-position in CCL operates this way with vector streams (i.e. having the effect of truncation), David Mullen often does low-level tricks like writing directly to the underlying vector. This gets into the internals (specifically: stuff that's private to the CCL package) and isn't exactly safe code, since it assumes there is already space in the buffer, and would otherwise need to call %extend-vector-output-stream (directly or indirectly):
An example (possibly unwise):
As of this writing, that gives #(164 231 121 229) corresponding to the universal time 3849971620.
Which—the careful programmer will note—doesn't overflow 32 (unsigned) bits. That'll happen in 2036.
Allegro CL
ACL has with-output-to-buffer:
Result of the above:
Which is similar to the result of with-output-to-string. The buffer wants to be a simple-array (and a vector, of course) with an element-type of either (unsigned-byte 8) or (signed-byte 8). Passing a non-simple array as the second argument can have peculiar effects. Consider this example, where the version of ACL is noted in the comment, and the default optimization settings are in effect:
Then we have this output from ACL's Debug Window:
CG-USER(4): *buffer* #(0 0 0 0 0 0 0 0 0 0 ...) CG-USER(5): *displaced* #<Printer Error, obj=#x21712102: Attempt to take the car of 231574861 which is not listp.> CG-USER(6): (type-of *displaced*) (ARRAY (UNSIGNED-BYTE 8) (10)) CG-USER(7): (aref *displaced* 0) Error: Attempt to take the car of 231574861 which is not listp. [condition type: TYPE-ERROR] CG-USER(8): (length *displaced*) 214731852
As the saying goes: "Don't do that, then."
Programming Tips