Post by Didier VernaHi,
on second thought, I'm forwarding this to sbcl-devel because I think
this might be a bug. The same scenario works fine with CCL. CMUCL gives
CL-USER> (test 'a 'b)
; In: TEST 'A
; (TEST 'A 'B)
; ==>
; (LET (#)
; (SETQ #:G0 #)
; #:G0)
; Note: Variable LISP::BACKQ-COMMA defined but never used.
; ;
; #:G0 OBJ
; (A B)
CL-USER> (macroexpand '(test 'a 'b))
(LET ((LISP::BACKQ-COMMA OBJ))
(SETQ #:G4368 (LIST 'A 'B))
#:G4368)
T
---------- Forwarded message ----------
Date: Fri, 11 Oct 2013 09:14:06 +0200
Subject: multiple string reads/writes of SB-IMPL::BAKQ-COMMA
Hello,
the backquote syntax gives me a problem when doing multiple (in fact 2)
CL-USER> (defmacro test (&body body)
(let ((obj (gensym)))
`(let (,obj)
,obj)))
TEST
CL-USER> (test 'foo 'bar)
(FOO BAR)
CL-USER> (with-input-from-string (s "(defmacro test (&body body)
(let ((obj (gensym)))
`(let (,obj)
,obj)))")
(eval (read s)))
STYLE-WARNING: redefining COMMON-LISP-USER::TEST in DEFMACRO
TEST
CL-USER> (test 'foo 'bar)
(FOO BAR)
;; Okay, but then...
CL-USER> (with-input-from-string (s "(defmacro test (&body body)
(let ((obj (gensym)))
`(let (,obj)
,obj)))")
(eval (with-input-from-string (s (prin1-to-string (read s)))
(read s))))
STYLE-WARNING: redefining COMMON-LISP-USER::TEST in DEFMACRO
TEST
CL-USER> (test 'foo 'bar)
; in: TEST 'FOO
; (LET ((SB-IMPL::BACKQ-COMMA OBJ))
; (SETQ #:G2191 (LIST 'FOO 'BAR))
; #:G2191)
;
; The variable SB-IMPL::BACKQ-COMMA is defined but never used.
; (SETQ #:G2191 (LIST 'FOO 'BAR))
;
; undefined variable: #:G2191
and it breaks. What happens is that in the first case, SBCL understands
that (SB-IMPL::BACKQ-COMMA OBJ) really means ,obj in the let form, but
if I read this expression, write it to a string and read it again for
evaluation, then it thinks that I'm trying to bind SB-IMPL::BACKQ-COMMA
to OBJ...
How can I avoid this behavior ?
Thanks !
--
Resistance is futile. You will be jazzimilated.
Lisp, Jazz, Aïkido: http://www.didierverna.info
--
Resistance is futile. You will be jazzimilated.
Lisp, Jazz, Aïkido: http://www.didierverna.info
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most
from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134071&iu=/4140/ostg.clktrk
_______________________________________________
Sbcl-devel mailing list
https://lists.sourceforge.net/lists/listinfo/sbcl-devel