aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/emacs-lisp/cl-macs.el13
2 files changed, 14 insertions, 6 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index b5a4857f9f8..2554bd6d83a 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12013-08-29 Stefan Monnier <monnier@iro.umontreal.ca>
2
3 * emacs-lisp/cl-macs.el (cl-defsubst): Make it clear that args
4 are immutable. Don't use `unsafe' any more.
5 (cl--defsubst-expand): Don't substitute at the same time as keeping
6 a residual unused let-binding. Don't use `unsafe' any more.
7
12013-08-29 Glenn Morris <rgm@gnu.org> 82013-08-29 Glenn Morris <rgm@gnu.org>
2 9
3 * calendar/cal-china.el (calendar-chinese-year-cache): 10 * calendar/cal-china.el (calendar-chinese-year-cache):
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index d9d6658811f..af7c41d5c4c 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2693,15 +2693,16 @@ macro that returns its `&whole' argument."
2693;;;###autoload 2693;;;###autoload
2694(defmacro cl-defsubst (name args &rest body) 2694(defmacro cl-defsubst (name args &rest body)
2695 "Define NAME as a function. 2695 "Define NAME as a function.
2696Like `defun', except the function is automatically declared `inline', 2696Like `defun', except the function is automatically declared `inline' and
2697the arguments are immutable.
2697ARGLIST allows full Common Lisp conventions, and BODY is implicitly 2698ARGLIST allows full Common Lisp conventions, and BODY is implicitly
2698surrounded by (cl-block NAME ...). 2699surrounded by (cl-block NAME ...).
2700The function's arguments should be treated as immutable.
2699 2701
2700\(fn NAME ARGLIST [DOCSTRING] BODY...)" 2702\(fn NAME ARGLIST [DOCSTRING] BODY...)"
2701 (declare (debug cl-defun) (indent 2)) 2703 (declare (debug cl-defun) (indent 2))
2702 (let* ((argns (cl--arglist-args args)) (p argns) 2704 (let* ((argns (cl--arglist-args args)) (p argns)
2703 (pbody (cons 'progn body)) 2705 (pbody (cons 'progn body)))
2704 (unsafe (not (cl--safe-expr-p pbody))))
2705 (while (and p (eq (cl--expr-contains args (car p)) 1)) (pop p)) 2706 (while (and p (eq (cl--expr-contains args (car p)) 1)) (pop p))
2706 `(progn 2707 `(progn
2707 ,(if p nil ; give up if defaults refer to earlier args 2708 ,(if p nil ; give up if defaults refer to earlier args
@@ -2717,10 +2718,10 @@ surrounded by (cl-block NAME ...).
2717 ;; does not pay attention to the argvs (and 2718 ;; does not pay attention to the argvs (and
2718 ;; cl-expr-access-order itself is also too naive). 2719 ;; cl-expr-access-order itself is also too naive).
2719 nil 2720 nil
2720 ,(and (memq '&key args) 'cl-whole) ,unsafe ,@argns))) 2721 ,(and (memq '&key args) 'cl-whole) nil ,@argns)))
2721 (cl-defun ,name ,args ,@body)))) 2722 (cl-defun ,name ,args ,@body))))
2722 2723
2723(defun cl--defsubst-expand (argns body simple whole unsafe &rest argvs) 2724(defun cl--defsubst-expand (argns body simple whole _unsafe &rest argvs)
2724 (if (and whole (not (cl--safe-expr-p (cons 'progn argvs)))) whole 2725 (if (and whole (not (cl--safe-expr-p (cons 'progn argvs)))) whole
2725 (if (cl--simple-exprs-p argvs) (setq simple t)) 2726 (if (cl--simple-exprs-p argvs) (setq simple t))
2726 (let* ((substs ()) 2727 (let* ((substs ())
@@ -2728,7 +2729,7 @@ surrounded by (cl-block NAME ...).
2728 (cl-mapcar (lambda (argn argv) 2729 (cl-mapcar (lambda (argn argv)
2729 (if (or simple (macroexp-const-p argv)) 2730 (if (or simple (macroexp-const-p argv))
2730 (progn (push (cons argn argv) substs) 2731 (progn (push (cons argn argv) substs)
2731 (and unsafe (list argn argv))) 2732 nil)
2732 (list argn argv))) 2733 (list argn argv)))
2733 argns argvs)))) 2734 argns argvs))))
2734 ;; FIXME: `sublis/subst' will happily substitute the symbol 2735 ;; FIXME: `sublis/subst' will happily substitute the symbol