From: Giorgos Pontikakis
Subject: macroexpand in cmucl
Date: 
Message-ID: <1136753061.842956.283130@g47g2000cwa.googlegroups.com>
Dear group,

trying to understand nested backquotes, I define the following macro
(from Paul Graham's On Lisp):

(defmacro abbrev (short long)
  `(defmacro ,short (&rest args)
    `(,',long ,@args)))

and I try to evaluate
(macroexpand-1 '(abbrev mvb multiple-value-bind))

In sbcl (version 0.9.5) I get
(DEFMACRO MVB (&REST ARGS) `(MULTIPLE-VALUE-BIND ,@ARGS))
which is what I expected.

In cmucl (version 19c) I get:
Error in format: No more arguments.
  ~:<~^~W~^~5I ~:_~W~3I ··@·······@{ ··@_~W~}~:>
                             ^
   [Condition of type FORMAT::FORMAT-ERROR]

Restarts:
  0: [ABORT] Return to Top-Level.

Debug  (type H for help)

((FLET #:WITH-PRETTY-STREAM-6
   PRETTY-PRINT::PPRINT-MULTIPLE-VALUE-BIND)
 #<pretty stream {58021915}>)
Source: Error finding source:
Error in function DEBUG::GET-FILE-TOP-LEVEL-FORM:  Source file no
longer exists:
  target:code/pprint.lisp.

Why the error? Can anyone tell me what am I doing wrong?

Thank you,
Giorgos Pontikakis

From: Christophe Rhodes
Subject: Re: macroexpand in cmucl
Date: 
Message-ID: <sqlkxpzr2m.fsf@cam.ac.uk>
"Giorgos Pontikakis" <·······@gmail.com> writes:

> Dear group,
>
> trying to understand nested backquotes, I define the following macro
> (from Paul Graham's On Lisp):
>
> (defmacro abbrev (short long)
>   `(defmacro ,short (&rest args)
>     `(,',long ,@args)))
>
> and I try to evaluate
> (macroexpand-1 '(abbrev mvb multiple-value-bind))
>
> In sbcl (version 0.9.5) I get
> (DEFMACRO MVB (&REST ARGS) `(MULTIPLE-VALUE-BIND ,@ARGS))
> which is what I expected.
>
> In cmucl (version 19c) I get:
> Error in format: No more arguments.
>   ~:<~^~W~^~5I ~:_~W~3I ··@·······@{ ··@_~W~}~:>
>                              ^
>    [Condition of type FORMAT::FORMAT-ERROR]
>
> Restarts:
>   0: [ABORT] Return to Top-Level.
>
> Debug  (type H for help)
>
> ((FLET #:WITH-PRETTY-STREAM-6
>    PRETTY-PRINT::PPRINT-MULTIPLE-VALUE-BIND)
>  #<pretty stream {58021915}>)
> Source: Error finding source:
> Error in function DEBUG::GET-FILE-TOP-LEVEL-FORM:  Source file no
> longer exists:
>   target:code/pprint.lisp.
>
> Why the error? Can anyone tell me what am I doing wrong?

You're not; this is a bug in routines attached to CMUCL's pretty
printer.  Apparently the CMUCL maintainers have decided to add pretty
printing forms for Common Lisp's special operators, so that

  (multiple-value-bind (foo bar) (round 3.2 1.3) (frob) (frob))

would be printed as

  (multiple-value-bind
        (foo bar)
      (round 3.2 1.3)
    (frob)
    (frob))

(if all the newlines were needed).  However the implementation of this
has failed to be robust against the use of multiple-value-bind in
different contexts.

Christophe
From: Jens Axel Søgaard
Subject: Re: macroexpand in cmucl
Date: 
Message-ID: <43c270c9$0$38693$edfadb0f@dread12.news.tele.dk>
Giorgos Pontikakis wrote:
> Dear group,
> 
> trying to understand nested backquotes, I define the following macro
> (from Paul Graham's On Lisp):

You might enjoy Alan Bawden's "Quasiquotation in Lisp":
<http://www.linearity.org/bawden/ftp/quasiquote-v59.ps.gz>

-- 
Jens Axel S�gaard
From: Giorgos Pontikakis
Subject: Re: macroexpand in cmucl
Date: 
Message-ID: <1136832281.917269.143800@g47g2000cwa.googlegroups.com>
Thank both of you for the answers.

I suppose that this is a known bug and I should not be bothered
reporting it to the CMUCL maintainers.

And that paper of Alan Bawden was very helpful. Thanks for the link.

Giorgos
From: Raymond Toy
Subject: Re: macroexpand in cmucl
Date: 
Message-ID: <sxdwth8jdza.fsf@rtp.ericsson.se>
>>>>> "Giorgos" == Giorgos Pontikakis <·······@gmail.com> writes:

    Giorgos> I suppose that this is a known bug and I should not be bothered
    Giorgos> reporting it to the CMUCL maintainers.

You should have reported it to the maintainers, but someone else has
reported the problem (with a fix, too!).  It doesn't hurt, and I don't
know how often maintainers read comp.lang.lisp.

Anyway, you can find a patch for this bug at

http://common-lisp.net/webftp/pub/project/cmucl/release/19c/patches/cmucl-19c-patch-001.tar.gz

You either just download the file, untar it, use asdf to load the
patch, or just manually load the patch file.  

Alternatively, you should be able to use asdf-install to install this
patch.

Ray
From: Rob Warnock
Subject: Re: macroexpand in cmucl
Date: 
Message-ID: <lYednSPz6-TTA1nenZ2dnUVZ_tGdnZ2d@speakeasy.net>
Raymond Toy  <···········@ericsson.com> wrote:
+---------------
| Anyway, you can find a patch for this bug at
| http://common-lisp.net/webftp/pub/project/cmucl/release/19c/patches/cmucl-19c-patch-001.tar.gz
| 
| You either just download the file, untar it, use asdf to load the
| patch, or just manually load the patch file.  
+---------------

Hmmm... FWIW, it still fails for me even after loading the patch:

    $ $CMU19c/bin/lisp -noinit -nositeinit
    CMU Common Lisp 19c (19C), running on gar.agami.com
    With core: /usr/u/rpw3/src/cmd/cmucl-19c/lib/cmucl/lib/lisp.core
    Dumped on: Thu, 2005-11-17 06:12:58-08:00 on lorien
    See <http://www.cons.org/cmucl/> for support information.
    Loaded subsystems:
	Python 1.1, target Intel x86
	CLOS based on Gerd's PCL 2004/04/14 03:32:47
    * (load "src/cmd/cmucl-19c-patch-001/cmucl-19c-patch-001.lisp")

    ; Loading #P"/usr/u/rpw3/src/cmd/cmucl-19c-patch-001/cmucl-19c-patch-001.lisp".
    T
    * (defmacro abbrev (short long)
      `(defmacro ,short (&rest args)
	`(,',long ,@args)))

    ABBREV
    * (macroexpand-1 '(abbrev mvb multiple-value-bind))

    (DEFMACRO MVB (&REST ARGS)
      `(MULTIPLE-VALUE-BIND ,@ARGS

    Error in format: No more arguments.
      ~:<~^~W~^~5I ~:_~W~3I ··@·······@{ ··@_~W~}~:>
				 ^
       [Condition of type FORMAT::FORMAT-ERROR]

    Restarts:
      0: [ABORT] Return to Top-Level.

    Debug  (type H for help)

    ((FLET #:WITH-PRETTY-STREAM-6
       PRETTY-PRINT::PPRINT-MULTIPLE-VALUE-BIND)
     #<pretty stream {5801AEF5}>)
    Source: Error finding source: 
    Error in function DEBUG::GET-FILE-TOP-LEVEL-FORM:  Source file no longer exists:
      target:code/pprint.lisp.
    0] 


-Rob

p.s. Note that it works fine on CMUCL-19a:

    With core: /usr/u/rpw3/src/cmd/cmucl-19a/lib/cmucl/lib/lisp.core
    Dumped on: Wed, 2004-07-28 09:51:48-07:00 on lorien
    ...
    > (macroexpand-1 '(abbrev mvb multiple-value-bind))

    (DEFMACRO MVB (&REST ARGS) `(MULTIPLE-VALUE-BIND ,@ARGS))
    T
    > 

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Raymond Toy
Subject: Re: macroexpand in cmucl
Date: 
Message-ID: <sxdoe2ikgnk.fsf@rtp.ericsson.se>
>>>>> "Rob" == Rob Warnock <····@rpw3.org> writes:

    Rob> Hmmm... FWIW, it still fails for me even after loading the patch:

Argh.

How stupid of me.  I put the pushnew for :cmucl-19c-patch-001 at the
beginning of the file instead of the end.  If you move the pushnew to
the end, it works for me.

It works when compiled, though, which is what I did when I tested
this, via asdf.

I'll put up a patch-001a soon.

Ray
From: Rob Warnock
Subject: Re: macroexpand in cmucl
Date: 
Message-ID: <26OdnRn9RrYiR1jeRVn-rQ@speakeasy.net>
Raymond Toy  <···········@ericsson.com> wrote:
+---------------
| >>>>> "Rob" == Rob Warnock <····@rpw3.org> writes:
|  Rob> Hmmm... FWIW, it still fails for me even after loading the patch:
| 
| Argh.
| How stupid of me.  I put the pushnew for :cmucl-19c-patch-001 at the
| beginning of the file instead of the end.  If you move the pushnew to
| the end, it works for me.
+---------------

Yes, me too. *D'OH!* I should have seen it myself, since I had
already admired the #+(AND cmu19c (NOT cmucl-19c-patch-001))
in front of the SET-PPRINT-DISPATCH!!  ;-}  ;-}


-Rob

-----
Rob Warnock			<····@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607
From: Raymond Toy
Subject: Re: macroexpand in cmucl
Date: 
Message-ID: <sxdfynti0gx.fsf@rtp.ericsson.se>
>>>>> "Rob" == Rob Warnock <····@rpw3.org> writes:

    Rob> Raymond Toy  <···········@ericsson.com> wrote:
    Rob> +---------------
    Rob> | >>>>> "Rob" == Rob Warnock <····@rpw3.org> writes:
    Rob> |  Rob> Hmmm... FWIW, it still fails for me even after loading the patch:
    Rob> | 
    Rob> | Argh.
    Rob> | How stupid of me.  I put the pushnew for :cmucl-19c-patch-001 at the
    Rob> | beginning of the file instead of the end.  If you move the pushnew to
    Rob> | the end, it works for me.
    Rob> +---------------

    Rob> Yes, me too. *D'OH!* I should have seen it myself, since I had
    Rob> already admired the #+(AND cmu19c (NOT cmucl-19c-patch-001))
    Rob> in front of the SET-PPRINT-DISPATCH!!  ;-}  ;-}

Heh.  New patch available.  This one should work.  Look for
cmucl-19c-patch-001a.

Ray
From: Giorgos Pontikakis
Subject: Re: macroexpand in cmucl
Date: 
Message-ID: <1136832233.652684.66250@f14g2000cwb.googlegroups.com>
Thank both of you for the answers.

I suppose that this is a known bug and I should not be bothered
reporting it to the CMUCL maintainers.

And that paper of Alan Bawden was very helpful. Thanks for the link.

Giorgos