GNU bug report logs -
#59872
cl-labels and cl-flet do not comply with the documentation
Previous Next
To reply to this bug, email your comments to 59872 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
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):
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):
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 2 years and 69 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.