From: Michael Heerdegen <michael_heerdegen@web.de>
To: Stefan Monnier <monnier@IRO.UMontreal.CA>
Cc: emacs-devel@gnu.org
Subject: Re: pcase: Semantics of atom QPATS
Date: Sat, 16 Jun 2018 06:03:16 +0200 [thread overview]
Message-ID: <87vaaj9y4b.fsf@web.de> (raw)
In-Reply-To: <jwvwov2c0id.fsf-monnier+emacs@gnu.org> (Stefan Monnier's message of "Wed, 13 Jun 2018 08:52:25 -0400")
[-- Attachment #1: Type: text/plain, Size: 154 bytes --]
Stefan Monnier <monnier@IRO.UMontreal.CA> writes:
> Sure. Feel free to add support for floats while you're there.
Ok. Is this patch ok for emacs-26?
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Allow-floats-as-pcase-QPATS.patch --]
[-- Type: text/x-diff, Size: 2366 bytes --]
From f3088c97472e5edc84303dcf4ee4130e0eae17fa Mon Sep 17 00:00:00 2001
From: Michael Heerdegen <michael_heerdegen@web.de>
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}
-@itemx @var{integer}
+@itemx @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
[-- Attachment #3: Type: text/plain, Size: 12 bytes --]
Michael.
next prev parent reply other threads:[~2018-06-16 4:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-10 0:40 pcase: Semantics of atom QPATS Michael Heerdegen
2018-06-11 14:09 ` Stefan Monnier
2018-06-11 14:45 ` Drew Adams
2018-06-11 15:24 ` Stefan Monnier
2018-06-11 20:53 ` Michael Heerdegen
2018-06-13 3:41 ` Michael Heerdegen
2018-06-13 12:52 ` Stefan Monnier
2018-06-16 4:03 ` Michael Heerdegen [this message]
2018-06-16 6:57 ` Eli Zaretskii
2018-06-16 7:32 ` Michael Heerdegen
2018-06-16 7:49 ` Eli Zaretskii
2018-06-17 13:35 ` Michael Heerdegen
2018-06-16 13:42 ` Noam Postavsky
2018-06-16 12:57 ` 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
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87vaaj9y4b.fsf@web.de \
--to=michael_heerdegen@web.de \
--cc=emacs-devel@gnu.org \
--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 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).