GNU bug report logs - #59872
cl-labels and cl-flet do not comply with the documentation

Previous Next

Package: emacs;

Reported by: Rafael D Sorkin <rsorkin <at> perimeterinstitute.ca>

Date: Wed, 7 Dec 2022 06:02:02 UTC

Severity: normal

To reply to this bug, email your comments to 59872 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#59872; Package emacs. (Wed, 07 Dec 2022 06:02:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Rafael D Sorkin <rsorkin <at> perimeterinstitute.ca>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 07 Dec 2022 06:02:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Rafael D Sorkin <rsorkin <at> perimeterinstitute.ca>
To: bug-gnu-emacs <at> gnu.org
Cc: Rafael D Sorkin <rsorkin <at> perimeterinstitute.ca>
Subject: cl-labels and cl-flet do not comply with the documentation
Date: Wed,  7 Dec 2022 01:01:26 -0500 (EST)
Hi,

The documentation that I received along with emacs 28.2 says
about `cl-flet' that 

  "... the function body is enclosed in an implicit block as if by `cl-defun'".  

(This is from     
   File: cl.info,  Node: Function Bindings,  Next: Macro Bindings,  Prev: Dynamic Bindings,  Up: Variable Bindings
   4.3.2 Function Bindings
   -----------------------)

I expected this behavior precisely because of the parallel with
`cl-defun', as well as the connotation of the prefix "cl-"
itself, which leads on to expect that `cl-flet' and `cl-labels'
would act like their CL counterparts.

However, as far as I can tell, neither of these functions
actually creates an implicit named block, as claimed.
Below is the evidence (from emacs 26.3, but 28.2 is similar).
One sees that only `flet' works, but it has been declared as
"obsolete".


Thanks,
Rafael

emacs-version                                              ; 26.3
(require 'cl-lib)                                          ; cl-lib

(flet     ((tester () (return-from tester 3)))   (tester)) ; 3
(labels   ((tester () (return-from tester 3)))   (tester)) ; No catch for tag: --cl-block-tester--, 3
(cl-flet  ((tester () (return-from tester 3)))   (tester)) ; No catch for tag: --cl-block-tester--, 3
(cl-labels((tester () (return-from tester 3)))   (tester)) ; No catch for tag: --cl-block-tester--, 3

(Macroexpand '(cl-labels ((tester () (return-from tester 3))))) ; (let (#:--cl-tester--) (setq #:--cl-tester-- (function (lambda nil (throw (quote --cl-block-tester--) 3)))))

(Macroexpand '(cl-flet   ((tester () (return-from tester 3))))) ; (let* ((#:--cl-tester-- (cl-function (lambda nil (return-from tester 3))))) (progn))

(Macroexpand '(labels  ((tester () (return-from tester 3))))) ; (progn (defvar #:--cl---cl-tester----) (let ((#:--cl---cl-tester---- nil)) (let* ((#:v (quote #:--cl---cl-tester----))) (set #:v (function (lambda nil (throw (quote --cl-block-tester--) 3)))))))

(Macroexpand '(flet     ((tester () (return-from tester 3))))) ; (let* ((#:vnew (cl-function (lambda nil (cl-block tester (return-from tester 3))))) (#:old (symbol-function (quote tester)))) (unwind-protect (fset (quote tester) #:vnew) (fset (quote tester) #:old)))

~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
 Rafael Sorkin
 Perimeter Institute for Theoretical Physics
 31 Caroline Street North
 Waterloo, ON  N2L 2Y5
 Canada
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#59872; Package emacs. (Sat, 10 Dec 2022 23:14:01 GMT) Full text and rfc822 format available.

Message #8 received at 59872 <at> debbugs.gnu.org (full text, mbox):

From: Michael Heerdegen <michael_heerdegen <at> web.de>
To: Rafael D Sorkin <rsorkin <at> perimeterinstitute.ca>
Cc: 59872 <at> debbugs.gnu.org
Subject: Re: bug#59872: cl-labels and cl-flet do not comply with the
 documentation
Date: Sun, 11 Dec 2022 00:12:49 +0100
Rafael D Sorkin <rsorkin <at> perimeterinstitute.ca> writes:

> The documentation that I received along with emacs 28.2 says about
> `cl-flet' that
>
> "... the function body is enclosed in an implicit block as if by
> `cl-defun'".

> However, as far as I can tell, neither of these functions
> actually creates an implicit named block, as claimed.

I think you are absolutely right, thanks for reporting this.  Seems
implementing that feature had just been forgotten when the cl-lib
versions were written.

Michael.




This bug report was last modified 1 year and 131 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.