all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: emacs-devel@gnu.org
Subject: Re: pcase: Semantics of atom QPATS
Date: Mon, 11 Jun 2018 10:09:37 -0400	[thread overview]
Message-ID: <jwvwov5jurg.fsf-monnier+gmane.emacs.devel@gnu.org> (raw)
In-Reply-To: 87tvqbjwyf.fsf@web.de

> isn't it strange that the pattern '.7 matches .7, but `.7 causes an
> error when used?

Yes and no: the pattern '<anything> is defined to match using (equal
x '<anything>), no matter what.  In contrast, ` behaves differently
depending on the type of the backquoted object and it only supports
a limited set of types (those documented in its docstring).

So it's normal for the two to behave differently.

> IMO the analogy to the list of self-quoting atoms (strings, keywords,
> integers - I'm all for that) is misguided here - something implicitly
> quoted in a backquoted pattern (i.e. something that is not unquoted)
> should behave like quoted with `'' (i.e. transformed into an `eq' test),
> everything else feels inconsistent.

[ It's an `equal` test we want, not `eq`.  ]

The issue is rather that not all types might want an `equal` test.
E.g. we could accept patterns like

    `#s(hash-table (data ,key1 ,val1))

Which is why I prefer signaling an error: it lets us extend the
semantics of ` without any fear of breaking backward compatibility.

But yes: it makes sense to extend pcase's ` pattern to accept floats and
match them with `equal` since it's easy and there doesn't seem to be
many other semantics to choose anyway.



        Stefan




  reply	other threads:[~2018-06-11 14:09 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 [this message]
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
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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=jwvwov5jurg.fsf-monnier+gmane.emacs.devel@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=emacs-devel@gnu.org \
    /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.