all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Adam Porter <adam@alphapapa.net>
To: emacs-devel@gnu.org
Subject: Re: [PATCH] pcase.el: Add type pattern
Date: Tue, 10 Mar 2020 13:04:52 -0500	[thread overview]
Message-ID: <87h7yw84sb.fsf@alphapapa.net> (raw)
In-Reply-To: 871rq0qf5w.fsf@web.de

Michael Heerdegen <michael_heerdegen@web.de> writes:

>> 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.
>
> Oh, I missed that, then sorry for the noise.

No problem.  Thanks.

>> 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)
>
> No, I don't see that here.  I'm using current master here.

Hm, I don't know how to explain that.  I guess I'll have to rebuild
master and check again.

>> 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.
>
> What effect does this have?  Since it's no defmacro from, the form is
> just copied literally to the generated loaddefs file, right?  Wouldn't
> that make a an explicit `require' in the definition necessary?

The (pcase-defmacro type) form expands to:

  (progn
    (defun type--pcase-macroexpander
        (type)
      ;; [long docstring omitted here]
      `(pred
        (pcase--flip cl-typep ',type)))
    (define-symbol-prop 'type--pcase-macroexpander 'edebug-form-spec 'nil)
    (define-symbol-prop 'type 'pcase-macroexpander #'type--pcase-macroexpander))

My understanding is that the autoload cookie causes the entire
cl-macs.el file to be loaded when the type--pcase-macroexpander function
is called, which then causes cl-lib to be loaded.  So an additional
(require 'cl-lib) would be redundant.  However, as I said, there are
nuances to autoloading that I haven't grokked yet, so I may be missing
something.




  reply	other threads:[~2020-03-10 18:04 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-09 18:19 [PATCH] pcase.el: Add type pattern Adam Porter
2020-03-09 18:38 ` Eli Zaretskii
2020-03-09 19:20   ` Adam Porter
2020-03-09 19:35     ` Adam Porter
2020-03-09 18:38 ` Adam Porter
2020-03-09 18:45 ` Eric Abrahamsen
2020-03-10 15:48   ` Adam Porter
2020-03-10 17:40     ` Eric Abrahamsen
2020-03-09 18:53 ` Stefan Monnier
2020-03-09 19:31   ` Adam Porter
2020-03-09 21:00     ` Stefan Monnier
2020-03-09 21:54       ` Adam Porter
2020-03-09 22:22         ` Michael Heerdegen
2020-03-09 22:46           ` Adam Porter
2020-03-10 14:54             ` Michael Heerdegen
2020-03-10 15:01             ` Michael Heerdegen
2020-03-10 15:46               ` Adam Porter
2020-03-10 16:24                 ` Michael Heerdegen
2020-03-10 17:03                   ` Adam Porter
2020-03-10 17:43                     ` Michael Heerdegen
2020-03-10 18:04                       ` Adam Porter [this message]
2020-03-10 18:17                         ` Adam Porter
2020-03-10 19:07                           ` Michael Heerdegen
2020-03-10 19:19                             ` Adam Porter
2020-03-10 19:10                           ` Eric Abrahamsen
2020-03-10 19:21                             ` Adam Porter
2020-03-11  2:08                         ` Michael Heerdegen
2020-03-16 12:59                 ` Stefan Monnier
2021-07-11  1:33                   ` [PATCH] pcase.el: Add cl-type and type patterns Adam Porter
2021-07-11  2:12                     ` Adam Porter
2021-07-11  6:11                       ` Eli Zaretskii
2021-07-16  9:32                         ` Adam Porter
2021-07-17 11:58                           ` Eli Zaretskii
2021-07-16 22:41                       ` Stefan Monnier
2021-07-17 16:07                         ` Adam Porter
2021-07-30 21:24                           ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87h7yw84sb.fsf@alphapapa.net \
    --to=adam@alphapapa.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.