backquote of constants should be constant

Bug #1026439 reported by James Y Knight
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Wishlist
Unassigned

Bug Description

That is,
(defconstant +foo+ 1)
(defun foo () `(,+foo+))
should return a constant list, not cons up a new one every time.

Here's a patch. Seems to work.

I wonder if any of the complication in backq.lisp can be removed if it can assume the compiler does this.

Tags: review
Revision history for this message
James Y Knight (foom) wrote :
Revision history for this message
Stas Boukarev (stassats) wrote :

"Should" as in "the standard prescribes it" or in "it would be nice"?

tags: added: review
Changed in sbcl:
importance: Undecided → Wishlist
Revision history for this message
James Y Knight (foom) wrote :

Should as in "this is a significant missed optimization".

Revision history for this message
James Y Knight (foom) wrote :

BTW, here's some discussions about whether the result of backquote is considered mutable or not. The spec is not very clear, but it seems like the consensus is that backquote can return literal data whenever it feels like it. Which is good, because SBCL already does that in many cases. This just adds a few more cases. :)

https://groups.google.com/group/comp.lang.lisp/browse_thread/thread/74c41c41aeb80528
https://groups.google.com/group/comp.lang.lisp/browse_thread/thread/43e14ad1ba72dd0d
https://groups.google.com/group/comp.lang.lisp/browse_thread/thread/385f2adf7a3175fd

Paul Khuong (pvk)
Changed in sbcl:
status: New → Triaged
assignee: nobody → Paul Khuong (pvk)
Paul Khuong (pvk)
Changed in sbcl:
status: Triaged → In Progress
Revision history for this message
Paul Khuong (pvk) wrote :

Committed in f250391 (Constant-fold backquote of constant expressions)

Changed in sbcl:
status: In Progress → Fix Committed
assignee: Paul Khuong (pvk) → nobody
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.