emacs-devel
[Top][All Lists]
Advanced

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

Re: pcase: Semantics of atom QPATS


From: Michael Heerdegen
Subject: Re: pcase: Semantics of atom QPATS
Date: Sat, 16 Jun 2018 06:03:16 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux)

Stefan Monnier <address@hidden> writes:

> Sure.  Feel free to add support for floats while you're there.

Ok.  Is this patch ok for emacs-26?

>From f3088c97472e5edc84303dcf4ee4130e0eae17fa Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <address@hidden>
Date: Wed, 13 Jun 2018 04:37:38 +0200
Subject: [PATCH] Allow floats as 'pcase' QPATS

* lisp/emacs-lisp/pcase.el (\`): Extend semantics of QPATS to all
numbers.  Add a comment explaining why we disallow some atoms as
QPATS.
* doc/lispref/control.texi (Backquote Patterns): Update the paragraph
explaining QPATS.  Remove a sentence suggesting an analogy between
QPATS to self-quoting objects.
---
 doc/lispref/control.texi | 4 +---
 lisp/emacs-lisp/pcase.el | 7 +++++--
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/doc/lispref/control.texi b/doc/lispref/control.texi
index 34f5f57044..975ab3d075 100644
--- a/doc/lispref/control.texi
+++ b/doc/lispref/control.texi
@@ -1090,12 +1090,10 @@ Backquote Patterns
 
 @item @var{symbol}
 @itemx @var{keyword}
address@hidden @var{integer}
address@hidden @var{number}
 @itemx @var{string}
 Matches if the corresponding element of @var{expval} is
 @code{equal} to the specified literal object.
-Note that, aside from @var{symbol}, this is the same set of
-self-quoting literal objects that are acceptable as a core pattern.
 
 @item ,@var{pattern}
 Matches if the corresponding element of @var{expval}
diff --git a/lisp/emacs-lisp/pcase.el b/lisp/emacs-lisp/pcase.el
index fa7b1de8b4..4a69244d26 100644
--- a/lisp/emacs-lisp/pcase.el
+++ b/lisp/emacs-lisp/pcase.el
@@ -919,7 +919,7 @@ pcase--u1
   ,PAT                  matches if the `pcase' pattern PAT matches.
   SYMBOL                matches if EXPVAL is `equal' to SYMBOL.
   KEYWORD               likewise for KEYWORD.
-  INTEGER               likewise for INTEGER.
+  NUMBER                likewise for NUMBER.
   STRING                likewise for STRING.
 
 The list or vector QPAT is a template.  The predicate formed
@@ -949,7 +949,10 @@ pcase--u1
     `(and (pred consp)
           (app car ,(list '\` (car qpat)))
           (app cdr ,(list '\` (cdr qpat)))))
-   ((or (stringp qpat) (integerp qpat) (symbolp qpat)) `',qpat)
+   ((or (stringp qpat) (numberp qpat) (symbolp qpat)) `',qpat)
+   ;; In all other cases just raise an error so we can't break
+   ;; backward compatibility when adding \` support for other
+   ;; compounded values that are not `consp'
    (t (error "Unknown QPAT: %S" qpat))))
 
 (provide 'pcase)
-- 
2.17.1



Michael.

reply via email to

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