[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] pcase.el: Add cl-type and type patterns

From: Adam Porter
Subject: [PATCH] pcase.el: Add cl-type and type patterns
Date: Sat, 10 Jul 2021 20:33:24 -0500
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Hi Stefan, et al,

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>> Thanks, that's a good point.  This new patch improves the docstring
>> and the changes to the manual, and it adds a test for a cl-typep list
>> form.  Please let me know if more improvements should be made.
> The code looks good, except for the fact that it only works after
> (require 'cl-lib), so if we want to put it into `cl-lib` like that, we
> should use a name like `cl-type` rather than `type`.

Revisiting this patch from last year (thread here:

I'm attaching two new patches, rebased on current master:

1.  The first implements the new cl-type-based matcher, renamed to
`cl-type' as requested.

2.  The second applies on top of the first and, like the initial patch
proposed in the thread, adds a "dumb" `type' matcher which just uses a
`TYPEp' or `TYPE-p' predicate as appropriate.  My rationale for also
adding this matcher is for writing concise code: with only the cl-type
matcher, the equivalent `pred' matcher is shorter:

  (pred integerp)
  (cl-type integer)

But by also adding `type', for simple types, we can do better, having
the best of clarity and conciseness:

  (type integer)

Since it was decided that the cl-type-based matcher was preferable as an
alternative to the "dumb" matcher (due to cl-type's extra power, and its
correctness in matching structs defined with custom predicate names), I
propose this as a separate patch; if having both is not acceptable, the
second patch may be omitted.


Attachment: 0001-lisp-emacs-lisp-cl-macs.el-Add-cl-type-pattern.patch
Description: cl-type-based pcase matcher

Attachment: 0002-lisp-emacs-lisp-pcase.el-Add-type-pattern.patch
Description: "dumb" type pcase matcher

reply via email to

[Prev in Thread] Current Thread [Next in Thread]