in cl-store loop over lists with implicit destructuring-bind on assoc lists fails
Describe the problem here.
(ql:quickload :cl-store)
(ql:quickload :flexi-streams)
(flex:with-output-to-sequence (io)
(cl-store:store (cons "a" "b") io))
Describe expected result and what provide the output you got.
Expected:
#(67 76 67 76 43 5 1 1 97 1 5 1 1 98)
but got:
Condition of type: STORE-ERROR
"b" is not of type LIST.
Possible Workarounds: edit default-backend.lisp in cl-store
reduce safety
(defun iterative-list-store (list stream)
+ (declare (optimize (safety 0)))
(output-type-code +iterative-cons-code+ stream)
(loop for (object . remaining) on list :do
(store-object object stream)
(cond ((atom remaining)
(store-list-code *eol-code* stream)
(store-object remaining stream)
(return))
((and *check-for-circs* (gethash remaining *stored-values*))
(store-list-code *eol-code* stream)
(store-referrer *current-backend* (get-ref remaining) stream)
(return))
(t (store-list-code *cdr-code* stream)))))
or
manually destructure binding
(defun iterative-list-store (list stream)
(output-type-code +iterative-cons-code+ stream)
(loop for iter on list :do
+ (destructuring-bind (object . remaining) iter
(store-object object stream)
(cond ((atom remaining)
(store-list-code *eol-code* stream)
(store-object remaining stream)
(return))
((and *check-for-circs* (gethash remaining *stored-values*))
(store-list-code *eol-code* stream)
(store-referrer *current-backend* (get-ref remaining) stream)
(return))
(t (store-list-code *cdr-code* stream))))))
Provide details regarding ECL version (or preferably commit), operating system and if revelant the build options and versions of the build tools.
(lisp-implementation-version) "16.1.3"
(ext:lisp-implementation-vcs-id)` "e45b808aa82a86b40b477c3f4a2021c335b5f5e"
(software-type) "Linux"
(software-version) "4.13.11-xanmod18"
(machine-type) "x86_64"
*features* (:FLEXI-STREAMS :QUICKLISP :ASDF3.3 :ASDF3.2 :ASDF3.1 :ASDF3 :ASDF2 :ASDF
:OS-UNIX :NON-BASE-CHARS-EXIST-P :ASDF-UNICODE :WALKER :CDR-1 :CDR-5 :LINUX
:FORMATTER :CDR-7 :ECL-WEAK-HASH :LITTLE-ENDIAN :ECL-READ-WRITE-LOCK
:LONG-LONG :UINT64-T :UINT32-T :UINT16-T :LONG-FLOAT :UNICODE :DFFI
:CLOS-STREAMS :CMU-FORMAT :UNIX :ECL-PDE :DLOPEN :CLOS :THREADS :BOEHM-GC
:ANSI-CL :COMMON-LISP :IEEE-FLOATING-POINT :PACKAGE-LOCAL-NICKNAMES :CDR-14
:PREFIXED-API :FFI :X86_64 :COMMON :ECL)