From: Brian D. <bdo...@la...> - 2004-06-06 21:43:42
|
[Apologies to cmucl-imp denizens, I sent the first message to sbc...@so..., instead of lists.sourceforge.net. Please don't group-reply to that one, it won't work.] I discovered this trying to come up with an example to show the guts of the backquote engine to someone on #lisp. With *PRINT-PRETTY* T, a backquote expression prints correctly through PRINT but incorrectly returned to the REPL. The same behavior is seen in CMUCL, so it's probably code that hasn't changed in a long while: (This is on Mac OS X 10.3) (as seen on http://www.common-lisp.net/paste/display/1199:) ---------------------------------------------------------------------- :; sbcl This is SBCL 0.8.10, an implementation of ANSI Common Lisp. More information about SBCL is available at <http://www.sbcl.org/>. SBCL is free software, provided as is, with absolutely no warranty. It is mostly in the public domain; some portions are provided under BSD-style licenses. See the CREDITS and COPYING files in the distribution for more information. * (print '`(foobar a b ,c ,'(e f g) d ,@'(e f g) (h i j) ,@foo)) `(FOOBAR A B ,C (E F G) D E F G (H I J) ,@FOO) `(FOOBAR A B ,C (E F G) D E F G (H I J) ,@FOO (H I J) ,@FOO) * (setq *print-pretty* nil) NIL * (print '`(foobar a b ,c ,'(e f g) d ,@'(e f g) (h i j) ,@foo)) (SB-IMPL::BACKQ-LIST* (QUOTE FOOBAR) (QUOTE A) (QUOTE B) C (QUOTE (E F G)) (QUOTE D) (SB-IMPL::BACKQ-APPEND (QUOTE (E F G)) (SB-IMPL::BACKQ-CONS (QUOTE (H I J)) FOO))) (SB-IMPL::BACKQ-LIST* (QUOTE FOOBAR) (QUOTE A) (QUOTE B) C (QUOTE (E F G)) (QUOTE D) (SB-IMPL::BACKQ-APPEND (QUOTE (E F G)) (SB-IMPL::BACKQ-CONS (QUOTE (H I J)) FOO))) ---------------------------------------------------------------------- :; lisp CMU Common Lisp darwin-exp 2004-01-28-020, running on ruth With core: /usr/local/encap/cmucl-0.2004.02.03.010/lib/cmucl/lib/lisp.core Dumped on: Wed, 2004-01-28 13:09:40-06:00 on PMSF-iBook.local. See <http://www.cons.org/cmucl/> for support information. Loaded subsystems: Python 1.1, target PowerPC CLOS based on Gerd's PCL 2003/06/18 09:23:09 * (print '`(foobar a b ,c ,'(e f g) d ,@'(e f g) (h i j) ,@foo)) `(FOOBAR A B ,C (E F G) D E F G (H I J) ,@FOO) `(FOOBAR A B ,C (E F G) D E F G (H I J) ,@FOO (H I J) ,@FOO) * (setq *print-pretty* nil) NIL * (print '`(foobar a b ,c ,'(e f g) d ,@'(e f g) (h i j) ,@foo)) (LISP::BACKQ-LIST* (QUOTE FOOBAR) (QUOTE A) (QUOTE B) C (QUOTE (E F G)) (QUOTE D) (LISP::BACKQ-APPEND (QUOTE (E F G)) (LISP::BACKQ-CONS (QUOTE (H I J)) FOO))) (LISP::BACKQ-LIST* (QUOTE FOOBAR) (QUOTE A) (QUOTE B) C (QUOTE (E F G)) (QUOTE D) (LISP::BACKQ-APPEND (QUOTE (E F G)) (LISP::BACKQ-CONS (QUOTE (H I J)) FOO))) ---------------------------------------------------------------------- Lispworks gets it right: CL-USER 6 > (print '`(foobar a b ,c ,'(e f g) d ,@'(e f g) (h i j) ,@foo)) (SYSTEM::BQ-LIST* (QUOTE FOOBAR) (QUOTE A) (QUOTE B) C (QUOTE (E F G)) (QUOTE D) (SYSTEM::BQ-APPEND (QUOTE (E F G)) (SYSTEM::BQ-LIST* (QUOTE (H I J)) FOO))) (SYSTEM::BQ-LIST* (QUOTE FOOBAR) (QUOTE A) (QUOTE B) C (QUOTE (E F G)) (QUOTE D) (SYSTEM::BQ-APPEND (QUOTE (E F G)) (SYSTEM::BQ-LIST* (QUOTE (H I J)) FOO))) CL-USER 7 > (setq *print-pretty* t) T CL-USER 8 > (print '`(foobar a b ,c ,'(e f g) d ,@'(e f g) (h i j) ,@foo)) `(FOOBAR A B ,C (E F G) D E F G (H I J) ,@FOO) `(FOOBAR A B ,C (E F G) D E F G (H I J) ,@FOO) -bcd |