sbcl.sbcl/tests/backq-const-fold.impure-cload.lisp
Charles Zhang 746f87ccd1 Don't try to fold named constant references inside backquote anymore
The gain for doing so was fairly marginal. The thing that really
mattered with the change adding the folding was telling the difference
between a named constant and anonymous constant inside the backq
constant folder, for the sake of sane load form semantics.

Not backq-constant-folding named constant references removes a
load-form hack which also just doesn't work with deferred TLF
processing, as the load form may get evaluated for value before the
constant definition for the named constant is evaluated.
2022-05-02 01:06:14 -07:00

21 lines
541 B
Common Lisp

;;; Example from Jan Moringen
(eval-when (:compile-toplevel :load-toplevel :execute)
(defclass foo () ()))
(defconstant +foo+
(if (boundp '+foo+)
+foo+
(make-instance 'foo)))
;;; The `(,+foo+) expression was being compile-time-folded to (#<foo
;;; xxxx>). Consequently it was unclear whether the #<foo> inside that
;;; list should require a load-form. We now track whether something
;;; comes from a named constant reference and dump the constant
;;; appropriately.
(defun foo ()
`(,+foo+))
(defun bar ()
`#(,+foo+))