[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Some improvements for cl-flet
From: |
Stefan Monnier |
Subject: |
Re: Some improvements for cl-flet |
Date: |
Sun, 12 Sep 2021 22:26:31 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) |
> (cl-flet ((multilinep (apply-partially #'string-match-p "\n")))
> (pcase something
> ((and (pred stringp) (pred multilinep)) ...)
> ...))
FWIW, this is better written as
(cl-flet ((multilinep (s) (string-match-p "\n" s)))
...)
which is both shorter and more efficient. But there are other cases
where the "simple" form of `cl-flet` is more efficient and the CL
version would need to be of the form
(flet ((FOO (&rest args) (apply BAR args)))
...)
or worse
(let ((bar (BAR BAZ))
(flet ((FOO (&rest args) (apply bar args)))
...)
which would introduce a significant inefficiency and which can be
difficult for the compiler to optimize back to the efficiency of the
code that our `cl-flet` gets without any effort.
Its true that our `cl-flet` introduces an incompatibility with CL's
semantics, but I considered that it's sufficiently minor that the
tradeoff is worth it (as compared to introducing a separate new form).
Stefan
- Some improvements for cl-flet, akater, 2021/09/11
- [PATCH] Some improvements for cl-flet, akater, 2021/09/23
- Re: [PATCH] Some improvements for cl-flet, akater, 2021/09/23
- Re: [PATCH] Some improvements for cl-flet, João Távora, 2021/09/24
- Re: [PATCH] Some improvements for cl-flet, and some more, akater, 2021/09/24
- Re: [PATCH] Some improvements for cl-flet, and some more, João Távora, 2021/09/24
- Re: [PATCH] Some improvements for cl-flet, and some more, Lars Ingebrigtsen, 2021/09/24
- Re: [PATCH] Some improvements for cl-flet, and some more, João Távora, 2021/09/25
- Re: [PATCH] Some improvements for cl-flet, akater, 2021/09/24
- Re: [PATCH] Some improvements for cl-flet, Lars Ingebrigtsen, 2021/09/26
- Re: [PATCH] Some improvements for cl-flet, akater, 2021/09/26