all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Rafael D Sorkin <rsorkin@perimeterinstitute.ca>
To: 59872@debbugs.gnu.org
Cc: Rafael D Sorkin <rsorkin@perimeterinstitute.ca>
Subject: bug#59872: cl-labels and cl-flet do not comply with the documentation
Date: Wed,  7 Dec 2022 01:01:26 -0500 (EST)	[thread overview]
Message-ID: <20221207060126.21F713400241F@mn001.pi.local> (raw)

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
~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-





             reply	other threads:[~2022-12-07  6:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-07  6:01 Rafael D Sorkin [this message]
2022-12-10 23:12 ` bug#59872: cl-labels and cl-flet do not comply with the documentation Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221207060126.21F713400241F@mn001.pi.local \
    --to=rsorkin@perimeterinstitute.ca \
    --cc=59872@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.