APPROVE COMMIT
NOTE: This patch has been committed
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1531784981 -3600
# Tue Jul 17 00:49:41 2018 +0100
# Node ID e736ffdceecbe2b6a87040cd222fc8f6313bc575
# Parent dde704f40544aa0fe8eecbf2b92fbdbb7eeeb057
Improve vector handling, backquote.el
lisp/ChangeLog addition:
2018-07-17 Aidan Kehoe <kehoea(a)parhasard.net>
* backquote.el (bq-process-2):
Be better about handling vectors here; pass through constants,
call #'vector, #'vconcat directly at runtime if appropriate. Call
#'atom (which translates to bytecode) rather than #'vectorp first
within this function.
New #'bq-process-2 flag, vector*, which means "call apply
#'vector in the old way"
* backquote.el (bq-comma):
Don't check for numberp here, leave that to #'bq-process-1.
* backquote.el (bq-process-1):
Implement vector*. Call #'quote-maybe when appropriate, giving
more readable output.
diff -r dde704f40544 -r e736ffdceecb lisp/ChangeLog
--- a/lisp/ChangeLog Wed Jul 11 03:06:18 2018 +0100
+++ b/lisp/ChangeLog Tue Jul 17 00:49:41 2018 +0100
@@ -1,3 +1,18 @@
+2018-07-17 Aidan Kehoe <kehoea(a)parhasard.net>
+
+ * backquote.el (bq-process-2):
+ Be better about handling vectors here; pass through constants,
+ call #'vector, #'vconcat directly at runtime if appropriate. Call
+ #'atom (which translates to bytecode) rather than #'vectorp first
+ within this function.
+ New #'bq-process-2 flag, vector*, which means "call apply
+ #'vector in the old way"
+ * backquote.el (bq-comma):
+ Don't check for numberp here, leave that to #'bq-process-1.
+ * backquote.el (bq-process-1):
+ Implement vector*. Call #'quote-maybe when appropriate, giving
+ more readable output.
+
2018-07-05 Aidan Kehoe <kehoea(a)parhasard.net>
Silence an extensive list of byte compile warnings, chiefly
diff -r dde704f40544 -r e736ffdceecb lisp/backquote.el
--- a/lisp/backquote.el Wed Jul 11 03:06:18 2018 +0100
+++ b/lisp/backquote.el Tue Jul 17 00:49:41 2018 +0100
@@ -186,14 +186,26 @@
;;; This does the expansion from table 2.
(defun bq-process-2 (code)
- (cond ((vectorp code)
- (let* ((dflag-d (bq-process-2 (append code nil))))
- (cons 'vector (bq-process-1 (car dflag-d) (cdr dflag-d)))))
- ((atom code)
- (cond ((null code) (cons nil nil))
- ((or (numberp code) (eq code t))
- (cons t code))
- (t (cons 'quote code))))
+ (cond ((atom code)
+ (cond ((null code)
+ (cons nil nil))
+ ((vectorp code)
+ (let* ((dflag-d (bq-process-2 (append code nil)))
+ (dflag (car dflag-d))
+ (d (cdr dflag-d)))
+ (cond
+ ((memq dflag '(quote nil))
+ (cons t code))
+ ((eq dflag 'list)
+ (cons 'vector d))
+ ((eq dflag 'append)
+ ;; The idea for this is from GNU, thank you GNU. I don't
+ ;; like #'vconcat much, it's not very CL, but it does fit
+ ;; this use case, and there is no prospect of our
+ ;; removing it.
+ (cons 'vconcat d))
+ (t (cons 'vector* (bq-process-1 dflag d))))))
+ (t (cons 'quote code))))
((eq (car code) bq-at-marker)
(cons bq-at-flag (nth 1 code)))
((eq (car code) bq-dot-marker)
@@ -249,7 +261,7 @@
(cond ((atom code)
(cond ((null code)
(cons nil nil))
- ((or (numberp code) (eq code 't))
+ ((eq code t)
(cons t code))
(t (cons bq-comma-flag code))))
((eq (car code) 'quote)
@@ -262,13 +274,12 @@
;;; This handles table 1.
(defun bq-process-1 (flag thing)
- (cond ((or (eq flag bq-comma-flag)
- (memq flag '(t nil)))
+ (cond ((eq flag bq-comma-flag)
thing)
- ((eq flag 'quote)
- (list 'quote thing))
- ((eq flag 'vector)
- (list 'apply '(function vector) thing))
+ ((memq flag '(quote t nil))
+ (quote-maybe thing))
+ ((eq flag 'vector*)
+ (list 'apply '(function vector) thing))
(t (cons flag thing))))
(provide 'backquote)
--
‘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)