[Ecls-list] compiler-macro: spurious parameter reference?

Pascal J. Bourguignon pjb at informatimago.com
Sun Aug 29 16:37:12 UTC 2010



When compiling a compiler macro, the &whole form seems to be referenced even if it is not:



----(s.lisp)------------------------------------------------------------
(DEFUN IMPLODE-STRING (CHAR-SEQ)
  "
RETURN: A new string containing the characters in the sequence CHAR-SEQ.
"
  (MAP 'STRING (FUNCTION CHARACTER) CHAR-SEQ))


(DEFINE-COMPILER-MACRO IMPLODE-STRING (&WHOLE FORM  CHAR-SEQ)
  "
RETURN:  An optimized form for compiled code.
NOTE:    Unfortunately clisp does to take into account compiler-macros
         even when compiling...
"
  (DECLARE (IGNORE FORM))
  (WITH-GENSYMS (SEQ)
    `(LET ((,SEQ ,CHAR-SEQ))
       (TYPECASE ,SEQ
         (STRING     (COPY-SEQ ,SEQ))
         (LIST       (DO ((RESULT (MAKE-STRING (LENGTH ,SEQ)))
                          (I 0 (1+ I))
                          (SEQU ,SEQ  (CDR SEQU)))
                         ((NULL SEQU) RESULT)
                       (SETF (CHAR RESULT I) (CHARACTER (CAR SEQU)))))
         (OTHERWISE  (DO ((RESULT (MAKE-STRING (LENGTH ,SEQ)))
                          (I 0 (1+ I))
                          (MAX (LENGTH ,SEQ)))
                         ((>= I MAX) RESULT)
                       (SETF (CHAR RESULT I) (CHARACTER (AREF ,SEQ I)))))) )))

------------------------------------------------------------------------


CL-USER> (compile-file "/tmp/s.lisp")
;;;
;;; Compiling /tmp/s.lisp.
;;; OPTIMIZE levels: Safety=2, Space=0, Speed=3, Debug=3
;;;
;;; Compiling (DEFUN IMPLODE-STRING ...).
;;; Warning:
;;;   in file s.lisp, position 158
;;;   at (DEFINE-COMPILER-MACRO IMPLODE-STRING ...)
;;;   ! Variable FORM, declared as IGNORE, found in a lisp form.
;;; End of Pass 1.
;;; Emitting code for IMPLODE-STRING.
;;; Emitting code for IMPLODE-STRING.
;;; Note:
;;;   Invoking external command:
;;;   gcc "-I/usr/local/include/"  -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -g -O2 -fPIC  -D_THREAD_SAFE -Dlinux -O2 -w -c "/tmp/s.c" -o "/tmp/s.o"
;;; 
;;; Note:
;;;   Invoking external command:
;;;   gcc -o "/tmp/s.fas" -L"/usr/local/lib/" "/tmp/s.o"  "-Wl,--rpath,/usr/local/lib/" -shared    -lffi -lecl  -lgmp -lpthread -ldl  -lm 
;;; 
;;; Finished compiling /tmp/s.lisp.
;;;
#P"/tmp/s.fas"
T
NIL
CL-USER> 


-- 
__Pascal Bourguignon__                     http://www.informatimago.com/





More information about the ecl-devel mailing list