Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New pcase patterns such as cl-typep #55

Open
tarsius opened this issue Oct 16, 2024 · 3 comments
Open

New pcase patterns such as cl-typep #55

tarsius opened this issue Oct 16, 2024 · 3 comments
Labels

Comments

@tarsius
Copy link
Contributor

tarsius commented Oct 16, 2024

Please consider backporting newer pcase patterns such as cl-typep and eieio. Beside these two, there are probably some additional patterns that weren't available in the very first pcase. Such patterns are defined using pcase-defmacro, and take very little code.

Thanks for considering!

@minad
Copy link
Member

minad commented Oct 18, 2024

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.

@minad minad closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2024
@tarsius
Copy link
Contributor Author

tarsius commented Oct 18, 2024

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.

@tarsius
Copy link
Contributor Author

tarsius commented Oct 18, 2024

Iirc we've talked about this before?

We talked about pcase-setq.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants