[cl-store-devel] Fastest way to convert an object to a vector?

Chris Dean ctdean at sokitomi.com
Wed Jan 17 00:45:03 UTC 2007


I have an application where I need to convert an arbitrary Lisp object
into a C function that expects an array of characters.  What I do now
is use flexi-streams to convert to a Lisp vector, and then use some
FFI code to copy that vector to C array.  (The C code is the Berkeley
DB library.)

The flexi-streams form is called WITH-OUTPUT-TO-SEQUENCE, so the code
is very simple:

    (defun to-storage-vector (obj)
      (with-output-to-sequence (out) 
        (cl-store:store obj out)))

    (to-storage-vector 123) => #(67 108 115 84 24 0 1 123)  

Is there a way to do this same sort of operation using cl-store
directly and bypassing WITH-OUTPUT-TO-SEQUENCE ?  

Cheers,
Chris Dean



More information about the cl-store-devel mailing list