comparison lisp/bytecomp-runtime.el @ 5264:0d43872986b6

Change (apply 'nconc (mapcar ...)) to (mapcan ...); warn about first form. lisp/ChangeLog addition: 2010-09-16 Aidan Kehoe <kehoea@parhasard.net> * byte-optimize.el (byte-optimize-apply): Transform (apply 'nconc (mapcar ...)) to (mapcan ...); warn about use of the first idiom. * update-elc.el (do-autoload-commands): * packages.el (packages-find-package-library-path): * frame.el (frame-list): * extents.el (extent-descendants): * etags.el (buffer-tag-table-files): * dumped-lisp.el (preloaded-file-list): * device.el (device-list): * bytecomp-runtime.el (proclaim-inline, proclaim-notinline) Use #'mapcan, not (apply #'nconc (mapcar ...) in all these files. * bytecomp-runtime.el (eval-when-compile, eval-and-compile): In passing, mention that these macros also evaluate the body when interpreted.
author Aidan Kehoe <kehoea@parhasard.net>
date Thu, 16 Sep 2010 13:51:49 +0100
parents 018e13fdeaeb
children 311f6817efc2 308d34e9f07d
comparison
equal deleted inserted replaced
5263:0d436a78c514 5264:0d43872986b6
51 ;; FSF comments the next two out, but I see no reason to do so. --ben 51 ;; FSF comments the next two out, but I see no reason to do so. --ben
52 (defmacro proclaim-inline (&rest fns) 52 (defmacro proclaim-inline (&rest fns)
53 "Cause the named functions to be open-coded when called from compiled code. 53 "Cause the named functions to be open-coded when called from compiled code.
54 They will only be compiled open-coded when `byte-optimize' is true." 54 They will only be compiled open-coded when `byte-optimize' is true."
55 (cons 'eval-and-compile 55 (cons 'eval-and-compile
56 (apply 56 (mapcan
57 'nconc 57 #'(lambda (x)
58 (mapcar 58 `((or (memq (get ',x 'byte-optimizer)
59 #'(lambda (x) 59 '(nil byte-compile-inline-expand))
60 `((or (memq (get ',x 'byte-optimizer) 60 (error
61 '(nil byte-compile-inline-expand)) 61 "%s already has a byte-optimizer, can't make it inline"
62 (error 62 ',x))
63 "%s already has a byte-optimizer, can't make it inline" 63 (put ',x 'byte-optimizer 'byte-compile-inline-expand)))
64 ',x)) 64 fns)))
65 (put ',x 'byte-optimizer 'byte-compile-inline-expand)))
66 fns))))
67 65
68 66
69 (defmacro proclaim-notinline (&rest fns) 67 (defmacro proclaim-notinline (&rest fns)
70 "Cause the named functions to no longer be open-coded." 68 "Cause the named functions to no longer be open-coded."
71 (cons 'eval-and-compile 69 (cons 'eval-and-compile
72 (apply 70 (mapcan
73 'nconc 71 #'(lambda (x)
74 (mapcar 72 `((if (eq (get ',x 'byte-optimizer)
75 #'(lambda (x) 73 'byte-compile-inline-expand)
76 `((if (eq (get ',x 'byte-optimizer) 74 (put ',x 'byte-optimizer nil))))
77 'byte-compile-inline-expand) 75 fns)))
78 (put ',x 'byte-optimizer nil))))
79 fns))))
80 76
81 ;; This has a special byte-hunk-handler in bytecomp.el. 77 ;; This has a special byte-hunk-handler in bytecomp.el.
82 (defmacro defsubst (name arglist &rest body) 78 (defmacro defsubst (name arglist &rest body)
83 "Define an inline function. The syntax is just like that of `defun'." 79 "Define an inline function. The syntax is just like that of `defun'."
84 (or (memq (get name 'byte-optimizer) 80 (or (memq (get name 'byte-optimizer)
161 ;;; definition in the file overrides the magic definitions on the 157 ;;; definition in the file overrides the magic definitions on the
162 ;;; byte-compile-macro-environment. 158 ;;; byte-compile-macro-environment.
163 159
164 (put 'eval-when-compile 'lisp-indent-hook 0) 160 (put 'eval-when-compile 'lisp-indent-hook 0)
165 (defmacro eval-when-compile (&rest body) 161 (defmacro eval-when-compile (&rest body)
166 "Like `progn', but evaluates the body at compile time. 162 "Like `progn', but evaluates BODY at compile time, and when interpeted.
167 The result of the body appears to the compiler as a quoted constant." 163 The result of the body appears to the compiler as a quoted constant."
168 ;; Not necessary because we have it in b-c-initial-macro-environment 164 ;; Not necessary because we have it in b-c-initial-macro-environment
169 ;; (list 'quote (eval (cons 'progn body))) 165 ;; (list 'quote (eval (cons 'progn body)))
170 (cons 'progn body)) 166 (cons 'progn body))
171 167
172 (put 'eval-and-compile 'lisp-indent-hook 0) 168 (put 'eval-and-compile 'lisp-indent-hook 0)
173 (defmacro eval-and-compile (&rest body) 169 (defmacro eval-and-compile (&rest body)
174 "Like `progn', but evaluates the body at compile time and at load time." 170 "Like `progn', but evaluates the body at compile time and at load time,
171 and when interpreted."
175 ;; Remember, it's magic. 172 ;; Remember, it's magic.
176 (cons 'progn body)) 173 (cons 'progn body))
177 174
178 ;;; From Emacs 20. 175 ;;; From Emacs 20.
179 (put 'eval-when-feature 'lisp-indent-hook 1) 176 (put 'eval-when-feature 'lisp-indent-hook 1)