unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#16567: 24.3.50; pcase should signal an error if no case matches
@ 2014-01-27  9:22 Helmut Eller
  2014-01-27 10:27 ` Daimrod
                   ` (2 more replies)
  0 siblings, 3 replies; 27+ messages in thread
From: Helmut Eller @ 2014-01-27  9:22 UTC (permalink / raw)
  To: 16567

pcase returns nil for this example:

 (pcase 3
   (1 1)
   (2 2))

it would be more useful if it would signal an error instead.  Manually
adding a "catch-all case" and inventing some error message is tedious
and it's also easy to forget.





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  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-09-08 18:27 ` Leo Liu
  2014-09-08 19:19 ` Stefan Monnier
  2 siblings, 1 reply; 27+ messages in thread
From: Daimrod @ 2014-01-27 10:27 UTC (permalink / raw)
  To: Helmut Eller; +Cc: 16567

Helmut Eller <eller.helmut@gmail.com> writes:

> pcase returns nil for this example:
>
>  (pcase 3
>    (1 1)
>    (2 2))
>
> it would be more useful if it would signal an error instead.  Manually
> adding a "catch-all case" and inventing some error message is tedious
> and it's also easy to forget.

Wouldn't a `epcase' (as in `cl-ecase') be more appropriate for this
use-case?

-- 
Daimrod/Greg





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-01-27 10:27 ` Daimrod
@ 2014-01-27 11:56   ` Helmut Eller
  2014-01-27 12:23     ` Daimrod
  0 siblings, 1 reply; 27+ messages in thread
From: Helmut Eller @ 2014-01-27 11:56 UTC (permalink / raw)
  To: Daimrod; +Cc: 16567

On Mon, Jan 27 2014, Daimrod wrote:

> Helmut Eller <eller.helmut@gmail.com> writes:
>
>> pcase returns nil for this example:
>>
>>  (pcase 3
>>    (1 1)
>>    (2 2))
>>
>> it would be more useful if it would signal an error instead.  Manually
>> adding a "catch-all case" and inventing some error message is tedious
>> and it's also easy to forget.
>
> Wouldn't a `epcase' (as in `cl-ecase') be more appropriate for this
> use-case?

My gut feeling is that in 80% of all situations ECASE is more or just as
appropriate as CASE.  Or put differently it's very uncommon that CASE is
preferable to ECASE.  Therefore I think pcase should singal an error by
default.

The nice thing about a epcase would be the symmetry/analogy to
ECASE/ETYPECASE.  But that seems like a minor advantage.

Helmut





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-01-27 11:56   ` Helmut Eller
@ 2014-01-27 12:23     ` Daimrod
  0 siblings, 0 replies; 27+ messages in thread
From: Daimrod @ 2014-01-27 12:23 UTC (permalink / raw)
  To: Helmut Eller; +Cc: 16567

Helmut Eller <eller.helmut@gmail.com> writes:

> On Mon, Jan 27 2014, Daimrod wrote:
>
>> Helmut Eller <eller.helmut@gmail.com> writes:
>>
>>> pcase returns nil for this example:
>>>
>>>  (pcase 3
>>>    (1 1)
>>>    (2 2))
>>>
>>> it would be more useful if it would signal an error instead.  Manually
>>> adding a "catch-all case" and inventing some error message is tedious
>>> and it's also easy to forget.
>>
>> Wouldn't a `epcase' (as in `cl-ecase') be more appropriate for this
>> use-case?
>
> My gut feeling is that in 80% of all situations ECASE is more or just as
> appropriate as CASE.  Or put differently it's very uncommon that CASE is
> preferable to ECASE.  Therefore I think pcase should singal an error by
> default.
>
> The nice thing about a epcase would be the symmetry/analogy to
> ECASE/ETYPECASE.  But that seems like a minor advantage.

It also has the advantage of not breaking existing code that relies on
its current behavior, though I agree that most of the time I use ECASE
instead of CASE.

> Helmut

-- 
Daimrod/Greg





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  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-09-08 18:27 ` Leo Liu
  2014-09-08 19:19 ` Stefan Monnier
  2 siblings, 0 replies; 27+ messages in thread
From: Leo Liu @ 2014-09-08 18:27 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16567, Helmut Eller

On 2014-01-27 10:22 +0100, Helmut Eller wrote:
> pcase returns nil for this example:
>
>  (pcase 3
>    (1 1)
>    (2 2))
>
> it would be more useful if it would signal an error instead.  Manually
> adding a "catch-all case" and inventing some error message is tedious
> and it's also easy to forget.

Hi Stefan,

I also find myself wanting something as Helmut suggested more and more.
Any comments in the following patch? Thanks. Leo

=== 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-08 18:15:37 +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,14 @@
         ;; (puthash (car cases) `(,exp ,cases ,@expansion) pcase--memoize-2)
         expansion))))
 
+;;;###autoload
+(defmacro xcase (exp &rest cases)
+  (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 +290,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))))





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  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-09-08 18:27 ` Leo Liu
@ 2014-09-08 19:19 ` Stefan Monnier
  2014-09-08 20:58   ` Helmut Eller
  2 siblings, 1 reply; 27+ messages in thread
From: Stefan Monnier @ 2014-09-08 19:19 UTC (permalink / raw)
  To: Helmut Eller; +Cc: 16567

> pcase returns nil for this example:
>  (pcase 3
>    (1 1)
>    (2 2))
> it would be more useful if it would signal an error instead.  Manually
> adding a "catch-all case" and inventing some error message is tedious
> and it's also easy to forget.

The "nil default" is also very handy at times and pcase has been in use
for long enough that we can't really change this easily.

But we could add a new pcase-exhaustive macro that does that.


        Stefan





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-08 19:19 ` Stefan Monnier
@ 2014-09-08 20:58   ` Helmut Eller
  2014-09-09  0:41     ` Stefan Monnier
  0 siblings, 1 reply; 27+ messages in thread
From: Helmut Eller @ 2014-09-08 20:58 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16567

On Mon, Sep 08 2014, Stefan Monnier wrote:

>> pcase returns nil for this example:
>>  (pcase 3
>>    (1 1)
>>    (2 2))
>> it would be more useful if it would signal an error instead.  Manually
>> adding a "catch-all case" and inventing some error message is tedious
>> and it's also easy to forget.
>
> The "nil default" is also very handy at times and pcase has been in use
> for long enough that we can't really change this easily.

What could happen if you would change it?  Mostly some "no clause
matching" errors.  Arguably better than the current situation where
poeple forget the unintuitive default and receive no error message.

> But we could add a new pcase-exhaustive macro that does that.

Nobody wants to use such a long name.  The "nil default" would make more
sense in a pcase-if or pif macro.

Helmut





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-08 20:58   ` Helmut Eller
@ 2014-09-09  0:41     ` Stefan Monnier
  2014-09-10  0:02       ` Leo Liu
  0 siblings, 1 reply; 27+ messages in thread
From: Stefan Monnier @ 2014-09-09  0:41 UTC (permalink / raw)
  To: Helmut Eller; +Cc: 16567

> What could happen if you would change it?

Obviously: errors signaled instead of returning the expected nil.
Returning nil by default is "the norm" in Elisp (think of missing `else'
branches in `if', or missing default case in `cond' or even missing
default case in `cl-case'), so it's to be expected that pcase users
would rely on this default behavior as well, even if it strikes you as
utter nonsense.

> The "nil default" would make more sense in a pcase-if or pif macro.

Changing the default of `pcase' is not an option at this point.


        Stefan





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-09  0:41     ` Stefan Monnier
@ 2014-09-10  0:02       ` Leo Liu
  2014-09-10  2:26         ` Stefan Monnier
  0 siblings, 1 reply; 27+ messages in thread
From: Leo Liu @ 2014-09-10  0:02 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16567, Helmut Eller

On 2014-09-08 20:41 -0400, Stefan Monnier wrote:
> Changing the default of `pcase' is not an option at this point.

What's the way forward?

Leo





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-10  0:02       ` Leo Liu
@ 2014-09-10  2:26         ` Stefan Monnier
  2014-09-10  2:52           ` Leo Liu
  0 siblings, 1 reply; 27+ messages in thread
From: Stefan Monnier @ 2014-09-10  2:26 UTC (permalink / raw)
  To: Leo Liu; +Cc: 16567, Helmut Eller

>> Changing the default of `pcase' is not an option at this point.
> What's the way forward?

I suggested `pcase-exhaustive'.
You suggested `xcase', which I don't like for namespace reasons.


        Stefan





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-10  2:26         ` Stefan Monnier
@ 2014-09-10  2:52           ` Leo Liu
  2014-09-10  5:32             ` Josh
  2014-09-10 13:17             ` Stefan Monnier
  0 siblings, 2 replies; 27+ messages in thread
From: Leo Liu @ 2014-09-10  2:52 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16567, Helmut Eller

On 2014-09-09 22:26 -0400, Stefan Monnier wrote:
> I suggested `pcase-exhaustive'.
> You suggested `xcase', which I don't like for namespace reasons.

Would `pcasex' be acceptable? I used xcase because I cannot come up with
a good enough short name, and a long name for such a fundamental macro
can be annoying.

Thanks,
Leo





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  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
  1 sibling, 1 reply; 27+ messages in thread
From: Josh @ 2014-09-10  5:32 UTC (permalink / raw)
  To: Leo Liu; +Cc: 16567, Helmut Eller

[-- Attachment #1: Type: text/plain, Size: 702 bytes --]

On Tue, Sep 9, 2014 at 7:52 PM, Leo Liu <sdl.web@gmail.com> wrote:

> On 2014-09-09 22:26 -0400, Stefan Monnier wrote:
> > I suggested `pcase-exhaustive'.
> > You suggested `xcase', which I don't like for namespace reasons.
>
> Would `pcasex' be acceptable? I used xcase because I cannot come up with
> a good enough short name, and a long name for such a fundamental macro
> can be annoying.
>

How is the special case of erroring upon failure to match a "fundamental
macro"?
If this needs to exist then Stefan's suggestion of `pcase-exhaustive' or
some other
descriptive name seems like the way to go, but just appending "x" for the
sake of
brevity seems like a bad idea.  Clarity is more important.

[-- Attachment #2: Type: text/html, Size: 1148 bytes --]

^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-10  5:32             ` Josh
@ 2014-09-10  6:18               ` Helmut Eller
  0 siblings, 0 replies; 27+ messages in thread
From: Helmut Eller @ 2014-09-10  6:18 UTC (permalink / raw)
  To: Josh; +Cc: 16567, Leo Liu

On Tue, Sep 09 2014, Josh wrote:

> How is the special case of erroring upon failure to match a "fundamental
> macro"?

It's not a special case.  It's by far the most common case for me.

Helmut





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-10  2:52           ` Leo Liu
  2014-09-10  5:32             ` Josh
@ 2014-09-10 13:17             ` Stefan Monnier
  2014-09-10 14:28               ` Helmut Eller
                                 ` (3 more replies)
  1 sibling, 4 replies; 27+ messages in thread
From: Stefan Monnier @ 2014-09-10 13:17 UTC (permalink / raw)
  To: Leo Liu; +Cc: 16567, Helmut Eller

> Would `pcasex' be acceptable?

It's kind of ugly, and I'm not sure what the "x" stands for.

> I used xcase because I cannot come up with a good enough short name,
> and a long name for such a fundamental macro can be annoying.

`pcase-e TAB' should expand to `pcase-exhaustive', so the length is not
that troublesome, unless you're concerned about line-length and
indentation (in which case the length of `pcase-exhaustive' may indeed
occasionally force you to use an extra line).

I'm open to other suggestions, and `pcasex' is not unacceptable, so
I think we're closing in.


        Stefan





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  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
                                 ` (2 subsequent siblings)
  3 siblings, 1 reply; 27+ messages in thread
From: Helmut Eller @ 2014-09-10 14:28 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16567, Leo Liu

On Wed, Sep 10 2014, Stefan Monnier wrote:

> I'm open to other suggestions, and `pcasex' is not unacceptable, so
> I think we're closing in.

pcase* looks less exotic that pcasex; though it's harder to type.

BTW, I find it surprising that this doesn't signal an error:

(pcase-let ((`(1 ,x) '("foo")))
 x)

But I suspect that "it's not an option" to change pcase-let.

Helmut





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-10 13:17             ` Stefan Monnier
  2014-09-10 14:28               ` Helmut Eller
@ 2014-09-10 14:33               ` Leo Liu
  2014-09-10 16:54               ` Glenn Morris
  2014-09-10 17:39               ` Richard Stallman
  3 siblings, 0 replies; 27+ messages in thread
From: Leo Liu @ 2014-09-10 14:33 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16567, Helmut Eller

On 2014-09-10 09:17 -0400, Stefan Monnier wrote:
> unless you're concerned about line-length and
> indentation (in which case the length of `pcase-exhaustive' may indeed
> occasionally force you to use an extra line).
>
> I'm open to other suggestions, and `pcasex' is not unacceptable, so
> I think we're closing in.

pcasex = PCASe + EXhaustive

Yes, line length and indentation is my main concern. 

Leo





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-10 13:17             ` Stefan Monnier
  2014-09-10 14:28               ` Helmut Eller
  2014-09-10 14:33               ` Leo Liu
@ 2014-09-10 16:54               ` Glenn Morris
  2014-09-10 17:54                 ` Stefan Monnier
  2014-09-10 17:39               ` Richard Stallman
  3 siblings, 1 reply; 27+ messages in thread
From: Glenn Morris @ 2014-09-10 16:54 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16567, Helmut Eller, Leo Liu

Stefan Monnier wrote:

> I'm open to other suggestions, and `pcasex' is not unacceptable, so
> I think we're closing in.

And would you be prepared to add the
entirely-equivalent-but-somehow-we-managed-fine-without-them-all-this-time
condx and cl-casex?





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-10 14:28               ` Helmut Eller
@ 2014-09-10 17:26                 ` Stefan Monnier
  0 siblings, 0 replies; 27+ messages in thread
From: Stefan Monnier @ 2014-09-10 17:26 UTC (permalink / raw)
  To: Helmut Eller; +Cc: 16567, Leo Liu

>> I'm open to other suggestions, and `pcasex' is not unacceptable, so
>> I think we're closing in.
> pcase* looks less exotic that pcasex; though it's harder to type.
> BTW, I find it surprising that this doesn't signal an error:
> (pcase-let ((`(1 ,x) '("foo")))
>  x)

Indeed, the semantics of pcase-let is a bit subtle: rather than use the
pattern as a filter to decide whether to match or not, it just assumes
that the match is a success and accesses the data accordingly.

So the above expands to something morally equivalent to

   (let ((x (cadr '("foo")))) x)

> But I suspect that "it's not an option" to change pcase-let.

I don't think backward compatibility is as much of an issue for
pcase-let, but the motivation for this semantics was efficiency, and
this is still as valid as ever, AFAIK.

For single-branch pcase-let, the alternative

   (pcase-exhaustive '("foo")
     (`(1 ,x) x))

is a good replacement to get the semantics you expect.  But admittedly,
for if you have several bindings in your pcase-let, the equivalent
pcase-exhaustive can become inconvenient.


        Stefan





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-10 13:17             ` Stefan Monnier
                                 ` (2 preceding siblings ...)
  2014-09-10 16:54               ` Glenn Morris
@ 2014-09-10 17:39               ` Richard Stallman
  3 siblings, 0 replies; 27+ messages in thread
From: Richard Stallman @ 2014-09-10 17:39 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16567, eller.helmut, sdl.web

[[[ To any NSA and FBI agents reading my email: please consider    ]]]
[[[ whether defending the US Constitution against all enemies,     ]]]
[[[ foreign or domestic, requires you to follow Snowden's example. ]]]

pcasex means sex on a very small scale
;-)

-- 
Dr Richard Stallman
President, Free Software Foundation
51 Franklin St
Boston MA 02110
USA
www.fsf.org  www.gnu.org
Skype: No way! That's nonfree (freedom-denying) software.
  Use Ekiga or an ordinary phone call.






^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-10 16:54               ` Glenn Morris
@ 2014-09-10 17:54                 ` Stefan Monnier
  2014-09-12  2:35                   ` Leo Liu
  0 siblings, 1 reply; 27+ messages in thread
From: Stefan Monnier @ 2014-09-10 17:54 UTC (permalink / raw)
  To: Glenn Morris; +Cc: 16567, Helmut Eller, Leo Liu

>> I'm open to other suggestions, and `pcasex' is not unacceptable, so
>> I think we're closing in.
> And would you be prepared to add the
> entirely-equivalent-but-somehow-we-managed-fine-without-them-all-this-time
> condx and cl-casex?

We already have `cl-ecase'.  As for `condx', no I'd rather not ;-)


        Stefan





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-10 17:54                 ` Stefan Monnier
@ 2014-09-12  2:35                   ` Leo Liu
  2014-09-12 17:15                     ` Stefan Monnier
  0 siblings, 1 reply; 27+ messages in thread
From: Leo Liu @ 2014-09-12  2:35 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16567, Helmut Eller

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))))





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-12  2:35                   ` Leo Liu
@ 2014-09-12 17:15                     ` Stefan Monnier
  2014-09-13  0:29                       ` Leo Liu
  0 siblings, 1 reply; 27+ messages in thread
From: Stefan Monnier @ 2014-09-12 17:15 UTC (permalink / raw)
  To: Leo Liu; +Cc: 16567, Helmut Eller

> Which name would you prefer, `epcase' or 'pcasex'? Do you see any
> problems with the following patch (assume `pcasex' for now)?

For now, pcase-exhaustive is still a better choice.
A quick grep shows that most first args to pcase are rather short, so
the line-length argument is not very compelling.


        Stefan





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-12 17:15                     ` Stefan Monnier
@ 2014-09-13  0:29                       ` Leo Liu
  2014-09-13  3:10                         ` Stefan Monnier
  0 siblings, 1 reply; 27+ messages in thread
From: Leo Liu @ 2014-09-13  0:29 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16567, Helmut Eller

On 2014-09-12 13:15 -0400, Stefan Monnier wrote:
> For now, pcase-exhaustive is still a better choice.
> A quick grep shows that most first args to pcase are rather short, so
> the line-length argument is not very compelling.

OK, let's go with `pcase-exhaustive' for now. Any objection if we also
make an short alias to it for the convenience of people that know they
want the exhaustive version most of the time?

Leo





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-13  0:29                       ` Leo Liu
@ 2014-09-13  3:10                         ` Stefan Monnier
  2014-09-13  4:57                           ` Leo Liu
  0 siblings, 1 reply; 27+ messages in thread
From: Stefan Monnier @ 2014-09-13  3:10 UTC (permalink / raw)
  To: Leo Liu; +Cc: 16567, Helmut Eller

>> For now, pcase-exhaustive is still a better choice.
>> A quick grep shows that most first args to pcase are rather short, so
>> the line-length argument is not very compelling.
> OK, let's go with `pcase-exhaustive' for now. Any objection if we also
> make an short alias to it for the convenience of people that know they
> want the exhaustive version most of the time?

No, I'd rather wait to see if it's really used that often.  If it turns
out to be popular, we can then add a shorter version.


        Stefan





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-13  3:10                         ` Stefan Monnier
@ 2014-09-13  4:57                           ` Leo Liu
  2014-09-13 15:01                             ` Stefan Monnier
  0 siblings, 1 reply; 27+ messages in thread
From: Leo Liu @ 2014-09-13  4:57 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16567, Helmut Eller

On 2014-09-12 23:10 -0400, Stefan Monnier wrote:
> No, I'd rather wait to see if it's really used that often.  If it turns
> out to be popular, we can then add a shorter version.
>
>
>         Stefan

Should I install the patch (with the name change of course)?

Leo





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-13  4:57                           ` Leo Liu
@ 2014-09-13 15:01                             ` Stefan Monnier
  2014-09-13 17:25                               ` Leo Liu
  0 siblings, 1 reply; 27+ messages in thread
From: Stefan Monnier @ 2014-09-13 15:01 UTC (permalink / raw)
  To: Leo Liu; +Cc: 16567, Helmut Eller

>> No, I'd rather wait to see if it's really used that often.  If it turns
>> out to be popular, we can then add a shorter version.
> Should I install the patch (with the name change of course)?

Yes, go ahead,


        Stefan





^ permalink raw reply	[flat|nested] 27+ messages in thread

* bug#16567: 24.3.50; pcase should signal an error if no case matches
  2014-09-13 15:01                             ` Stefan Monnier
@ 2014-09-13 17:25                               ` Leo Liu
  0 siblings, 0 replies; 27+ messages in thread
From: Leo Liu @ 2014-09-13 17:25 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 16567-done, Helmut Eller

Version: 24.5

On 2014-09-13 11:01 -0400, Stefan Monnier wrote:
> Yes, go ahead,

Done.

Leo





^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2014-09-13 17:25 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).