From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Adam Porter Newsgroups: gmane.emacs.devel Subject: Re: [PATCH] pcase.el: Add type pattern Date: Tue, 10 Mar 2020 13:04:52 -0500 Message-ID: <87h7yw84sb.fsf@alphapapa.net> References: <874kuxxuez.fsf@alphapapa.net> <87r1y1wcj4.fsf@alphapapa.net> <87h7yxw5x1.fsf@alphapapa.net> <87a74puq1q.fsf@web.de> <87d09lw3id.fsf@alphapapa.net> <87zhcoqmmz.fsf@web.de> <87wo7s8b73.fsf@alphapapa.net> <87eeu0qisn.fsf@web.de> <87o8t487mb.fsf@alphapapa.net> <871rq0qf5w.fsf@web.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="129791"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Mar 10 19:06:00 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1jBjGS-000XbF-40 for ged-emacs-devel@m.gmane-mx.org; Tue, 10 Mar 2020 19:06:00 +0100 Original-Received: from localhost ([::1]:38030 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBjGR-0008UR-6M for ged-emacs-devel@m.gmane-mx.org; Tue, 10 Mar 2020 14:05:59 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:51132) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jBjFV-00075R-Qv for emacs-devel@gnu.org; Tue, 10 Mar 2020 14:05:03 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jBjFU-00033G-Pg for emacs-devel@gnu.org; Tue, 10 Mar 2020 14:05:01 -0400 Original-Received: from ciao.gmane.io ([159.69.161.202]:48094) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1jBjFU-0002xE-Ib for emacs-devel@gnu.org; Tue, 10 Mar 2020 14:05:00 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1jBjFS-000W2C-Ak for emacs-devel@gnu.org; Tue, 10 Mar 2020 19:04:58 +0100 X-Injected-Via-Gmane: http://gmane.org/ X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 159.69.161.202 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:245437 Archived-At: Michael Heerdegen 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.