emacs-devel
[Top][All Lists]
Advanced

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

Re: [PATCH] pcase.el: Add type pattern


From: Michael Heerdegen
Subject: Re: [PATCH] pcase.el: Add type pattern
Date: Tue, 10 Mar 2020 17:24:56 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Adam Porter <address@hidden> 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?

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?


Michael.



reply via email to

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