From: Leo Liu <sdl.web@gmail.com>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: 16567@debbugs.gnu.org, Helmut Eller <eller.helmut@gmail.com>
Subject: bug#16567: 24.3.50; pcase should signal an error if no case matches
Date: Fri, 12 Sep 2014 10:35:29 +0800 [thread overview]
Message-ID: <m3a965bm6m.fsf@gmail.com> (raw)
In-Reply-To: <jwvppf3gy4w.fsf-monnier+emacsbugs@gnu.org> (Stefan Monnier's message of "Wed, 10 Sep 2014 13:54:18 -0400")
Stefan,
Which name would you prefer, `epcase' or 'pcasex'? Do you see any
problems with the following patch (assume `pcasex' for now)?
Thanks, Leo
=== modified file 'lisp/emacs-lisp/lisp-mode.el'
--- lisp/emacs-lisp/lisp-mode.el 2014-06-19 14:03:45 +0000
+++ lisp/emacs-lisp/lisp-mode.el 2014-09-12 02:28:44 +0000
@@ -197,7 +197,7 @@
(el-vdefs '("defconst" "defcustom" "defvaralias" "defvar-local"
"defface"))
(el-tdefs '("defgroup" "deftheme"))
- (el-kw '("while-no-input" "letrec" "pcase" "pcase-let"
+ (el-kw '("while-no-input" "letrec" "pcase" "pcasex" "pcase-let"
"pcase-let*" "save-restriction" "save-excursion"
"save-selected-window"
;; "eval-after-load" "eval-next-after-load"
=== modified file 'lisp/emacs-lisp/pcase.el'
--- lisp/emacs-lisp/pcase.el 2014-09-06 00:59:00 +0000
+++ lisp/emacs-lisp/pcase.el 2014-09-10 10:44:59 +0000
@@ -68,6 +68,8 @@
(defconst pcase--dontcare-upats '(t _ pcase--dontcare))
+(defvar pcase--dontwarn-upats '(pcase--dontcare))
+
(def-edebug-spec
pcase-UPAT
(&or symbolp
@@ -148,6 +150,15 @@
;; (puthash (car cases) `(,exp ,cases ,@expansion) pcase--memoize-2)
expansion))))
+;;;###autoload
+(defmacro pcasex (exp &rest cases)
+ "The exhausitive version of `pcase' (which see)."
+ (declare (indent 1) (debug pcase))
+ (let* ((x (make-symbol "x"))
+ (pcase--dontwarn-upats (cons x pcase--dontwarn-upats)))
+ (pcase--expand
+ exp (append cases `((,x (error "No clause matching `%S'" ,x)))))))
+
(defun pcase--let* (bindings body)
(cond
((null bindings) (macroexp-progn body))
@@ -280,7 +291,8 @@
vars))))
cases))))
(dolist (case cases)
- (unless (or (memq case used-cases) (eq (car case) 'pcase--dontcare))
+ (unless (or (memq case used-cases)
+ (memq (car case) pcase--dontwarn-upats))
(message "Redundant pcase pattern: %S" (car case))))
(macroexp-let* defs main))))
next prev parent reply other threads:[~2014-09-12 2:35 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-01-27 9:22 bug#16567: 24.3.50; pcase should signal an error if no case matches Helmut Eller
2014-01-27 10:27 ` Daimrod
2014-01-27 11:56 ` Helmut Eller
2014-01-27 12:23 ` Daimrod
2014-09-08 18:27 ` Leo Liu
2014-09-08 19:19 ` Stefan Monnier
2014-09-08 20:58 ` Helmut Eller
2014-09-09 0:41 ` Stefan Monnier
2014-09-10 0:02 ` Leo Liu
2014-09-10 2:26 ` Stefan Monnier
2014-09-10 2:52 ` Leo Liu
2014-09-10 5:32 ` Josh
2014-09-10 6:18 ` Helmut Eller
2014-09-10 13:17 ` Stefan Monnier
2014-09-10 14:28 ` Helmut Eller
2014-09-10 17:26 ` Stefan Monnier
2014-09-10 14:33 ` Leo Liu
2014-09-10 16:54 ` Glenn Morris
2014-09-10 17:54 ` Stefan Monnier
2014-09-12 2:35 ` Leo Liu [this message]
2014-09-12 17:15 ` Stefan Monnier
2014-09-13 0:29 ` Leo Liu
2014-09-13 3:10 ` Stefan Monnier
2014-09-13 4:57 ` Leo Liu
2014-09-13 15:01 ` Stefan Monnier
2014-09-13 17:25 ` Leo Liu
2014-09-10 17:39 ` Richard Stallman
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=m3a965bm6m.fsf@gmail.com \
--to=sdl.web@gmail.com \
--cc=16567@debbugs.gnu.org \
--cc=eller.helmut@gmail.com \
--cc=monnier@IRO.UMontreal.CA \
/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.