Subject: Error in MACROS1.LSP & SERIES

From: "M. Thomas" <[email-masked]>
Date: Thu, 24 Feb 1994 16:24:46 -0500 (EST)

Hello, CLISPers,

The macroexpansion function for MULTIPLE-VALUE-SETQ in the file
MACROS1.LSP appears to be incorrect.  I found this error when trying to
run the test suite that comes with SERIES. (Latest version of CLISP for
DOS and SERIES macro package from usual U. Karlsruhe ftp site.)

> (multiple-value-setq (a b) (values 2 3))
2
> (list a b)
(2 3)
;;;  Everything is fine, since the CLISP evaluator apparently expands
;;;  a direct invocation of MULTIPLE-VALUE-SETQ as a special form.

> (pprint (macroexpand '(multiple-value-setq (a b) (values 2 3))))
(LET* ((#:G50 (MULTIPLE-VALUE-LIST (VALUES 2 3))))
 (PROG1 ((SETQ A (POP #:G50)) (SETQ B (POP #:G50))))
)
;;;  This macroexpansion is not correct; there's an extra pair of
;;;  parentheses enclosing the SETQ forms within the PROG1.
;;;  SERIES apparently evaluates the code returned by MACROEXPAND.

I found the macroexpander code for MULTIPLE-VALUE-SETQ in the file
"MACROS1.LSP".  I believe the original lines (marked by '-') should be
deleted, and lines marked by '+' added.  (Replacing LET* by LET is
purely cosmetic.)

(sys::%put 'multiple-value-setq 'sys::macro
  (sys::macro-expander multiple-value-setq (varlist form)
    (let ((g (gensym))
          (poplist nil))
      (dolist (var varlist) (setq poplist (cons `(SETQ ,var (POP ,g)) poplist)))
-     `(LET* ((,g (MULTIPLE-VALUE-LIST ,form)))
+     `(LET ((,g (MULTIPLE-VALUE-LIST ,form)))
-        ,(if poplist `(PROG1 ,(nreverse poplist)) NIL)
+        ,(if poplist `(PROG1 ,@(nreverse poplist)) NIL)
  ) )  )
)

By the way:
  (1)  SERIES fails 2 other tests in the test suite, because some
       macroexpansion creates a form like
           (TAGBODY <form> <form> ... NIL ... <form> ...),
       and CLISP does not allow NIL in such a context.  CLtL2, p. 175
       implies that NIL in such a context is (or should be) deprecated.
       To reproduce this error most easily:

> (load "series")     ;; series.fas, of course
> (series::install)
> (setq series::*series-implicit-map* T)
> (pprint (macroexpand '(collect-nth 1 (catenate #z() ((lambda () 2))))))

       Most likely suspect is a macroexpansion function within SERIES,
       but I don't know for sure.  If someone out there has encountered
       and solved this problem, please let me know (either by email or
       clisp-list). 

  (2)  The latest DOS distribution omitted the file about the X3J13 votes,
       I think it was called Cltl2.txt.

Thanks, and keep up the good work on CLISP.

Mark A. Thomas
[email-masked]