Open tarsius opened 1 month ago
Hi @tarsius,
I consider pcase extensions out of scope of Compat. The pcase library is simply too complex and too difficult to extend, since we have to work with the earliest versions. I've tried porting back pcase-related functionality before and I failed. Iirc we've talked about this before? Nevertheless I am happy to be proven wrong if it is indeed possible to port back certain subsets of the functionality.
I'm currently backporting the cl-typep
pattern in transient.el
like so:
(eval-and-compile ; Needed because we use this pattern below.
(when (< emacs-major-version 28)
(pcase-defmacro cl-type (type)
"Pcase pattern that matches objects of TYPE.
TYPE is a type descriptor as accepted by `cl-typep', which see."
(static-if (< emacs-major-version 30)
`(pred (pcase--flip cl-typep ',type))
;; This isn't actually ever used but we have to hide
;; the above from the byte-compiler for upcoming releases,
;; and might as well include this here to show what the
;; built-in version looks like in those upcoming releases.
`(pred (cl-typep _ ',type))))))
Seems simple enough.
Iirc we've talked about this before?
We talked about pcase-setq
.
Please consider backporting newer pcase patterns such as
cl-typep
andeieio
. Beside these two, there are probably some additional patterns that weren't available in the very firstpcase
. Such patterns are defined usingpcase-defmacro
, and take very little code.Thanks for considering!