Opened 3 years ago

Last modified 14 months ago

#477 new defect

COMPILE-FILE not doing minimal compilation in DEFCONSTANT/DEFPARAMETER/DEFVAR

Reported by: Mark Evenson Owned by:
Priority: major Milestone: 1.9.2
Component: compiler Version: 1.8.1-dev
Keywords: Cc:
Parent Tickets:

Description

In <https://mailman.common-lisp.net/pipermail/armedbear-devel/2020-November/004185.html> Robert Munyer reports

COMPILE-FILE is supposed to expand all macros in such a way that they
will not be expanded again when the compiled file is loaded.  (3.2.2.2)

The file below has 4 output lines that start with "*** Expanding macro".
None of those lines should be printed when the compiled file is loaded.

------- begin test-min-compilation.lisp -------

(macrolet ((m1 ()
             (format t "~&*** Expanding macro 1.~%")
             '(format t "~&Output of macro 1.~%")))
  (m1))

(defconstant +dc+
  (macrolet ((m2 ()
               (format t "~&*** Expanding macro 2 inside DEFCONSTANT.~%")
               '(format t "~&Output of macro 2.~%")))
    (m2)))

(defparameter *dp*
  (macrolet ((m3 ()
               (format t "~&*** Expanding macro 3 inside DEFPARAMETER.~%")
               '(format t "~&Output of macro 3.~%")))
    (m3)))

(defvar *dv*
  (macrolet ((m4 ()
               (format t "~&*** Expanding macro 4 inside DEFVAR.~%")
               '(format t "~&Output of macro 4.~%")))
    (m4)))

------- end test-min-compilation.lisp -------

CCL, CLISP, ECL and SBCL print none of the 4, ABCL prints 3 of the 4.

This one might be relatively easy, because ABCL is already handling
#1 correctly, and just needs to handle #2/3/4 in the same way as #1.

The rest of this message is the transcript.

$ java -jar abcl-344b4f66.jar
Armed Bear Common Lisp 1.8.1-dev
Java 1.8.0_272 Oracle Corporation
OpenJDK 64-Bit Server VM
Low-level initialization completed in 0.183 seconds.
Startup completed in 0.837 seconds.
Type ":help" for a list of available commands.
CL-USER(1): (compile-file "test-min-compilation.lisp")
; Compiling /tmp/foo/test-min-compilation.lisp ...
; (M1)
*** Expanding macro 1.
; (DEFCONSTANT +DC+ ...)
*** Expanding macro 2 inside DEFCONSTANT.
Output of macro 2.
; (DEFPARAMETER *DP* ...)
; (DEFVAR *DV* ...)
; Wrote /tmp/foo/test-min-compilation.abcl (0.163 seconds)
#P"/tmp/foo/test-min-compilation.abcl"
NIL
NIL
CL-USER(2): (load "test-min-compilation.abcl")
Output of macro 1.
*** Expanding macro 2 inside DEFCONSTANT.
Output of macro 2.
*** Expanding macro 3 inside DEFPARAMETER.
Output of macro 3.
*** Expanding macro 4 inside DEFVAR.
Output of macro 4.
T
CL-USER(3):

Change History (2)

comment:1 Changed 3 years ago by Mark Evenson

Version: 1.7.1-dev1.8.1-dev

comment:2 Changed 14 months ago by Mark Evenson

Milestone: 1.8.11.9.2
Note: See TracTickets for help on using tickets.