SB-CLTL2:PARSE-MACRO returns a NAMED-LAMBDA form

Bug #1545148 reported by Richard M Kreuter
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Undecided
Unassigned

Bug Description

Once upon a time, SB-CLTL2:PARSE-MACRO returned a lambda expression, but more recently it returns a NAMED-LAMBDA [1]. (It also appears to have sprouted a second return value too.) This both disagrees with Steele [2] and is arguably a new way to break formerly portable code walkers that use SB-CLTL2. ("Arguably" because such code walkers would have to handle NAMED-LAMBDA in other macros' expansions, but now they need to do so in more places.)

This probably happened in commit a86cac2825c24fc8f2c3bd01f7d0860bb71512c7, though SB-INT:MAKE-MACRO-LAMBDA was introduced in b336bb2495b3addeb7708e811bb694328584a83a.

Anyway, in order to revert SB-CLTL2:PARSE-MACRO to its old result, it looks like it might suffice to return `(lambda ,@(cddr (make-macro-lambda ...))), but I'm not sure.

(See also https://bugs.launchpad.net/sbcl/+bug/310097 for another report involving NAMED-LAMBDA; as in that case, it'd be friendlier for portable code walkers if SBCL offered a macroexpansion of NAMED-LAMBDA that didn't use implementation-dependent forms.)

[1] # Once...
$ ./run-sbcl.sh --no-userinit
(running SBCL from: .)
This is SBCL 1.2.11.0.sbcl-1.2.11.70-53fc0ef, 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.
* (require :sb-cltl2)

("SB-CLTL2")
* (sb-cltl2:parse-macro 'foo () ())

(LAMBDA (#:WHOLE536 #:ENVIRONMENT537)
  (DECLARE (IGNORE #:ENVIRONMENT537))
  (LET* ()
    (DECLARE (MUFFLE-CONDITIONS CODE-DELETION-NOTE))
    (LET ((#:ARGS539 (CDR #:WHOLE536)))
      (UNLESS (SB-INT:PROPER-LIST-OF-LENGTH-P #:ARGS539 0 0)
        (SB-KERNEL::ARG-COUNT-ERROR 'SB-CLTL2:PARSE-MACRO 'FOO #:ARGS539 'NIL 0
                                    0)))
    (LET* ()
      (BLOCK FOO))))

# Some old version I had handy:
$ ./run-sbcl.sh --no-userinit
(running SBCL from: .)
This is SBCL 1.3.2.69-aff4a0f, 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.
* (require "SB-CLTL2")

("SB-CLTL2")
* (sb-cltl2:parse-macro 'foo () ())

(SB-INT:NAMED-LAMBDA "FOO"
    (#:EXPR #:ENV)
  (DECLARE (SB-C::LAMBDA-LIST NIL))
  (DECLARE (IGNORE #:ENV))
  (SB-C::NAMED-DS-BIND (:MACRO FOO . SB-CLTL2:PARSE-MACRO)
      NIL
      (CDR #:EXPR)
    (BLOCK FOO)))
NIL

[2] http://www.cs.cmu.edu/Groups/AI/html/cltl/clm/node102.html

description: updated
Revision history for this message
Douglas Katzman (dougk) wrote :

The NAME argument is supposed to be used for something- what should it be used for if not to name the lambda? Error reporting, for which one could imagine that the implementation by which reporting that the error occurred in macro M is that M was its name.

For your second footnote you seem to be implicitly relying on http://www.lispworks.com/documentation/HyperSpec/Issues/iss156_w.htm
which says that standardized functions can't return extra values.
PARSE-MACRO isn't in the list, so I don't think the prohibition applies.

I don't think this is a bug, on either rationale, but I've changed it back since I don't care one way or the other.

https://sourceforge.net/p/sbcl/sbcl/ci/2b04ef41275d2eefaa770ec0b929af1d59e81ead/

Changed in sbcl:
status: New → Fix Committed
Stas Boukarev (stassats)
Changed in sbcl:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.