mirror of
git://git.code.sf.net/p/sbcl/sbcl
synced 2026-09-10 07:26:40 -04:00
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.
21 lines
541 B
Common Lisp
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+))
|