wanted: (SETF %FUN-NAME) on closures, or %SET-CLOSURE-NAME

Bug #520692 reported by Tobias C. Rittweiler
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
SBCL
Fix Released
Wishlist
Douglas Katzman

Bug Description

%FUN-NAME does not work on slot accessors, predicates, copiers
created by means of DEFSTRUCT.

Using (SETF %FUN-NAME) when creating the defstruct slot-accessors,
predicates, copiers won't do because (SETF %FUN-NAME) modifies the
underlying function of a closure, and all these are closures
sharing the same underlying function.

;;; Test case for defstruct.impure.lisp

;;; If this is fixed, uncomment the FUNCTION-TYPE+DEFSTRUCT.N tests in
;;; the SB-INTROSPECT contrib.

(with-test (:name defstruct+%fun-name)
  (assert (eq (sb-kernel:%fun-name #'person-age) 'person-age))
  (assert (eq (sb-kernel:%fun-name #'copy-person) 'copy-person))
  (assert (eq (sb-kernel:%fun-name #'person-p) 'person-p))
  (assert (eq (sb-kernel:%fun-name #'astro-helmet-size) 'astro-helmet-size))
  (assert (eq (sb-kernel:%fun-name #'copy-astronaut) 'copy-astronaut)))

description: updated
description: updated
summary: - SB-KERNEL:%FUN-NAME on functions created by DEFSTRUCT
+ wanted: (SETF %FUN-NAME) on closures, or %SET-CLOSURE-NAME
Changed in sbcl:
importance: Undecided → Wishlist
status: New → Confirmed
Revision history for this message
Douglas Katzman (dougk) wrote :

The implementation of defstruct accessors is different from what was described above - the predicate, copier, and accessors are genuine DEFUNs, not closures. As such, they have names.

Also, we have the ability to rename closures now (as of commit 111d187a4e82eb58f4013190ac330bc7c1efcc95), it operates in a way which may not meet users' expectations: naming a closure returns a new object.
So while I'm resolving this as "fixed", I don't think we should advertise named closures as a news item.

Changed in sbcl:
assignee: nobody → Douglas Katzman (dougk)
status: Confirmed → 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.