APPROVE COMMIT
NOTE: This patch has been committed
# HG changeset patch
# User Aidan Kehoe <kehoea(a)parhasard.net>
# Date 1524863122 -3600
#      Fri Apr 27 22:05:22 2018 +0100
# Node ID 8a7f058930de4b49190ad1381cba59dbfc93483d
# Parent  fd1fdfb2c336c61478e7a2ca0cd98ebab06a54d9
Add a byte-compile method for #'ignore, chiefly for generated code
lisp/ChangeLog addition:
2018-04-27  Aidan Kehoe  <kehoea(a)parhasard.net>
	* bytecomp.el:
	* bytecomp.el (ignore):
	* bytecomp.el (byte-compile-ignore): New.
	Add a byte-compile method for #'ignore, marking all its arguments
	as for-effect, and returning nil.
tests/ChangeLog addition:
2018-04-27  Aidan Kehoe  <kehoea(a)parhasard.net>
	* automated/lisp-tests.el:
	* automated/lisp-tests.el (null):
	Test #'ignore and its newly-added byte-compile method.
diff -r fd1fdfb2c336 -r 8a7f058930de lisp/ChangeLog
--- a/lisp/ChangeLog	Fri Apr 27 12:50:19 2018 +0100
+++ b/lisp/ChangeLog	Fri Apr 27 22:05:22 2018 +0100
@@ -1,3 +1,11 @@
+2018-04-27  Aidan Kehoe  <kehoea(a)parhasard.net>
+
+	* bytecomp.el:
+	* bytecomp.el (ignore):
+	* bytecomp.el (byte-compile-ignore): New.
+	Add a byte-compile method for #'ignore, marking all its arguments
+	as for-effect, and returning nil.
+
 2018-04-25  Aidan Kehoe  <kehoea(a)parhasard.net>
 
 	* subr.el (not): New.
diff -r fd1fdfb2c336 -r 8a7f058930de lisp/bytecomp.el
--- a/lisp/bytecomp.el	Fri Apr 27 12:50:19 2018 +0100
+++ b/lisp/bytecomp.el	Fri Apr 27 22:05:22 2018 +0100
@@ -4661,6 +4661,8 @@
 (byte-defop-compiler-1 defalias)
 (byte-defop-compiler-1 define-function)
 
+(byte-defop-compiler-1 ignore)
+
 (defun byte-compile-defun (form)
   ;; This is not used for file-level defuns with doc strings.
   (byte-compile-two-args ; Use this to avoid byte-compile-fset's warning.
@@ -4772,6 +4774,10 @@
     (if calls
 	(setq byte-compile-unresolved-functions
 	      (delete* calls byte-compile-unresolved-functions)))))
+
+(defun byte-compile-ignore (form)
+  (mapc #'byte-compile-form (cdr form) '#1=(t . #1#))
+  (unless for-effect (byte-compile-push-constant nil)))
 
 ;;; tags
 
diff -r fd1fdfb2c336 -r 8a7f058930de tests/ChangeLog
--- a/tests/ChangeLog	Fri Apr 27 12:50:19 2018 +0100
+++ b/tests/ChangeLog	Fri Apr 27 22:05:22 2018 +0100
@@ -1,3 +1,9 @@
+2018-04-27  Aidan Kehoe  <kehoea(a)parhasard.net>
+
+	* automated/lisp-tests.el:
+	* automated/lisp-tests.el (null):
+	Test #'ignore and its newly-added byte-compile method.
+
 2018-04-25  Aidan Kehoe  <kehoea(a)parhasard.net>
 
 	* automated/lisp-tests.el:
diff -r fd1fdfb2c336 -r 8a7f058930de tests/automated/lisp-tests.el
--- a/tests/automated/lisp-tests.el	Fri Apr 27 12:50:19 2018 +0100
+++ b/tests/automated/lisp-tests.el	Fri Apr 27 22:05:22 2018 +0100
@@ -3265,6 +3265,13 @@
       (Assert (not (funcall (intern "eq") #'bookend
#'refer-to-bookend))
 	      "checking two mutually recursive functions compiled OK"))))
 
+(Assert (null (ignore)) "checking ignore gives nil, no arguments")
+(Assert (null (ignore 40 90.5 pi))
+	"checking ignore gives nil, three arguments")
+(let (value)
+  (Assert (eq 'hi (prog2 (ignore (setq value 'hi)) value))
+	  "checking side-effecting statements not deleted, ignore"))
+
 ;; Test macroexpand's handling of the ENVIRONMENT argument. We augmented it
 ;; quietly for about four months, and this was incorrect.
 
-- 
‘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