GNU bug report logs -
#74870
cl-labels and cl-flet don't create named blocks
Previous Next
Full log
Message #20 received at 74870 <at> debbugs.gnu.org (full text, mbox):
> Is there any reason why one would not want to *always* emulate the CL
> behavior in cl-lib? I could only think of a backward compatibility
> problem before CL was standardized, but I am not familiar with the time
> frame of cl-lib to know if that's really the case.
Could you try the patch below?
Stefan
diff --git a/lisp/emacs-lisp/cl-macs.el b/lisp/emacs-lisp/cl-macs.el
index 65bc2cb9173..73741417383 100644
--- a/lisp/emacs-lisp/cl-macs.el
+++ b/lisp/emacs-lisp/cl-macs.el
@@ -2096,15 +2096,22 @@ cl-flet
cl-declarations body)))
(let ((binds ()) (newenv macroexpand-all-environment))
(dolist (binding bindings)
- (let ((var (make-symbol (format "--cl-%s--" (car binding))))
- (args-and-body (cdr binding)))
- (if (and (= (length args-and-body) 1)
- (macroexp-copyable-p (car args-and-body)))
+ (let* ((var (make-symbol (format "--cl-%s--" (car binding))))
+ (args-and-body (cdr binding))
+ (args (car args-and-body))
+ (body (cdr args-and-body)))
+ (if (and (null body)
+ (macroexp-copyable-p args))
;; Optimize (cl-flet ((fun var)) body).
- (setq var (car args-and-body))
- (push (list var (if (= (length args-and-body) 1)
- (car args-and-body)
- `(cl-function (lambda . ,args-and-body))))
+ (setq var args)
+ (push (list var (if (null body)
+ args
+ (let ((parsed-body (macroexp-parse-body body)))
+ `(cl-function
+ (lambda ,args
+ ,@(car parsed-body)
+ (cl-block ,(car binding)
+ ,@(cdr parsed-body)))))))
binds))
(push (cons (car binding)
(lambda (&rest args)
@@ -2300,7 +2307,13 @@ cl-labels
var (macroexpand-all
(if (null sbody)
sargs ;A (FUNC EXP) definition.
- `(cl-function (lambda ,sargs . ,sbody)))
+ (let ((parsed-body
+ (macroexp-parse-body sbody)))
+ `(cl-function
+ (lambda ,sargs
+ ,@(car parsed-body)
+ (cl-block ,var
+ ,@(cdr parsed-body))))))
newenv)))))
(nreverse binds))
. ,(macroexp-unprogn
This bug report was last modified 138 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.