From: Nico <ns...@zo...> - 2006-03-24 23:08:01
|
I trekked through all CLISP revisions from 2.33 to 2.38 to see where my problem is - any help/pointer will be appreciated. When I use 2.33 and everything works as expected. From revision 2.34 the code below does not work as expected. In essence, the 'reader' function defined by the def-i/o macro does not work. The 'set' form does not assign the variable that is read from file. This change in behaviour seems to coincide with the change to case insensitive CLISP. The implementation notes also mention the fact that macros may be problematic if different name spaces are used. If it is the case, what do I need to get the expected behaviour (as with 2.33) ? Thank you N Swart. ------------------------------------------- (cd "c:/mingw/home/src/memcut/jacs") (use-package :FFI) (default-foreign-language :stdc) (def-c-struct stform (dir uint8) (jauto uint8) (start uint8) (stop uint8) (maxspd sint16) (meth (c-array uint8 2)) (sname (c-array uint8 14)) (refstep (c-array uint8 2)) (refside (c-array uint8 2)) (valu (c-array sint16 2)) (mtpos sint16)) (def-c-var sequencetab (:name "sequencetab") (:library "jacs.dll") (:type (c-array stform 32)) (:read-only nil)) ;; From 'Successful Common Lisp' (defmacro def-i/o (writer-name reader-name (&rest vars)) (let ((file-name (gensym)) (var (gensym)) (stream (gensym))) `(progn (defun ,writer-name (,file-name) (with-open-file (,stream ,file-name :direction :output :if-exists :supersede) (dolist (,var (list ,@vars)) (declare (special ,@vars)) (print ,var ,stream)))) (defun ,reader-name (,file-name) (with-open-file (,stream ,file-name :direction :input :if-does-not-exist :error) (dolist (,var ',vars) (set ,var (read ,stream))))) t))) (def-i/o save-seq load-seq (sequencetab)) ;;Inits the variable sequencetab in 2.33, but not in subsequent versions ;;of CLISP (load-seq "Mandseq-file") |