Michael Heerdegen writes: > Adam Porter writes: > >> +(pcase-defmacro type (type) >> + "Pcase pattern that matches objects of TYPE. >> +TYPE is a symbol or list as accepted by `cl-typep', which see." >> + `(pred (pcase--flip cl-typep ',type))) >> + > > Is there a reason why you omit the (require 'cl-lib) call in the > definition as suggested by Stefan? My understanding was that adding the (require 'cl-lib) form was suggested if the definition was left in pcase.el, and if the definition were added to cl-macs.el instead, the (require 'cl-lib) form would not be needed. This made sense to me, because cl-macs.el has (require 'cl-lib) at the top of the file. Of course, I may have misunderstood, and there are nuances to autoloading and such that I don't fully understand. > With your definition in emacs -Q: > > (macroexpand-all '(pcase 10 ((type (integer 0 10)) t))) => > (if (cl-typep 10 '(integer 0 10)) (progn t) nil) > > With Stefan's version: > > (macroexpand-all '(pcase 10 ((type (integer 0 10)) t))) => > (if (and (integerp 10) (>= 10 '0) (<= 10 '10)) (progn t) nil) > > I.e. the type expression is treated at compile time and the dependency > to cl-lib is only at compile time, the compiled code has no dependency. > That should be better, no? Of course, that would be better. However, I was unable to reproduce those results on my end. Here are the steps I followed, both on my main Emacs 26.3 installation and on a build from near master: 1. Run emacs -Q. 2. Evaluate this form in *scratch*: (pcase-defmacro type (type) "Pcase pattern that matches objects of TYPE. TYPE is a symbol or list as accepted by `cl-typep', which see." `(pred (pcase--flip cl-typep ',type))) 3. Evaluate this form in *scratch*: (macroexpand-all '(pcase 10 ((type (integer 0 10)) t))) Result: (if (and (integerp 10) (>= 10 (quote 0)) (<= 10 (quote 10))) (progn t) nil) I haven't done much work on Emacs's core files before, so I may be doing something wrong. Please let me know. :) However, I have attached another version of the patch which adds an autoload for the (pcase-defmacro type) form, which seems proper since the (pcase-defmacro cl-struct) form in the same file also has one. Thanks for your help and feedback.