APPROVE COMMIT
NOTE: This patch has been committed
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1534161974 -3600
# Mon Aug 13 13:06:14 2018 +0100
# Node ID ebbb3bbb899aae849c9c66f4bc16825240be3637
# Parent 94cedc3ecd89c2c50ea4e3b1d5774459049f90af
Have distinct weak boxes print distinctly.
lisp/ChangeLog addition:
2018-08-13 Aidan Kehoe <kehoea(a)parhasard.net>
* misc.el (make-weak-box):
Have distinct weak boxes print distinctly; remove information on
the type of the one-time contents from the weak box, it doesn't
add anything and will be inaccurate once the contents are nil.
diff -r 94cedc3ecd89 -r ebbb3bbb899a lisp/ChangeLog
--- a/lisp/ChangeLog Sun Aug 12 21:27:46 2018 +0100
+++ b/lisp/ChangeLog Mon Aug 13 13:06:14 2018 +0100
@@ -1,3 +1,10 @@
+2018-08-13 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * misc.el (make-weak-box):
+ Have distinct weak boxes print distinctly; remove information on
+ the type of the one-time contents from the weak box, it doesn't
+ add anything and will be inaccurate once the contents are nil.
+
2018-08-12 Aidan Kehoe <kehoea(a)parhasard.net>
* misc.el:
diff -r 94cedc3ecd89 -r ebbb3bbb899a lisp/misc.el
--- a/lisp/misc.el Sun Aug 12 21:27:46 2018 +0100
+++ b/lisp/misc.el Mon Aug 13 13:06:14 2018 +0100
@@ -77,7 +77,7 @@
(defun weak-box-p (object)
"Return non-nil if OBJECT is a weak box."
- (and (vectorp object) (eql (length object) 3)
+ (and (vectorp object) (eql (length object) 2)
(eq 'cl-weak-box (aref object 0))))
(defun make-weak-box (contents)
@@ -88,21 +88,21 @@
`weak-box-ref' will return NIL."
(symbol-macrolet ((all-weak-boxes #:all-weak-boxes))
(defvar all-weak-boxes)
- (caar (set-weak-list-list
- (load-time-value
- (progn
- (setq all-weak-boxes (make-weak-list 'assoc))
- (defalias 'weak-box-ref-1
- #'(lambda (weak-box)
- (cdr (assq weak-box (weak-list-list all-weak-boxes)))))
- all-weak-boxes))
- ;; The #'eq-hash call isn't necessary, but it does mean that weak
- ;; boxes that refer to distinct objects print distinctly. The
- ;; #'type-of call is intended to give us a bit more context as to
- ;; what's going on, without the need to fire up GDB to convert the
- ;; eq-hash to an address.
- (acons (vector 'cl-weak-box (type-of contents) (eq-hash contents))
- contents (weak-list-list all-weak-boxes))))))
+ (let ((vector
+ (caar (set-weak-list-list
+ (load-time-value
+ (progn
+ (defalias 'weak-box-ref-1
+ #'(lambda (weak-box)
+ (cdr (assq weak-box
+ (weak-list-list all-weak-boxes)))))
+ (setq all-weak-boxes (make-weak-list 'assoc))))
+ (acons (vector 'cl-weak-box nil)
+ contents (weak-list-list all-weak-boxes))))))
+ ;; The second element of the vector is the eq hash of the vector itself,
+ ;; to ensure that distinct weak boxes print distinctly.
+ (aset vector 1 (eq-hash vector))
+ vector)))
(defun weak-box-ref (weak-box)
"Return the contents of weak box WEAK-BOX.
--
‘As I sat looking up at the Guinness ad, I could never figure out /
How your man stayed up on the surfboard after forty pints of stout’
(C. Moore)
Show replies by date