all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: Artur Malabarba <bruce.connor.am@gmail.com>, 20784@debbugs.gnu.org
Subject: bug#20784: 25.0.50; pcase documentation on t and nil
Date: Thu, 11 Jun 2015 12:22:28 -0400	[thread overview]
Message-ID: <jwva8w66xhp.fsf-monnier+emacsbugs@gnu.org> (raw)
In-Reply-To: <87r3pitmcb.fsf@web.de> (Michael Heerdegen's message of "Thu, 11 Jun 2015 15:18:28 +0200")

> (pcase 5.0
>   (5 5)
>   (5.0 5.0))  => 5.0

Hmm... indeed, I used "numbers" (and `numberp') in pcase, where I really
meant "integers".  That's a bug.  The above code should (IMO) signal an
error indicating that floats aren't accepted as patterns.  The intention
is that SELFQUOTING should always be matched with an `equal' semantics
(`eq' is used on integers and keywords as a plain optimization which
should not affect the semantics).
E.g. using `eq' on strings makes string patterns simply unusable.

> The case of t is especially non-obvious; it's neither treated as

Yes, it was a mistake to accept t to mean the same as `_'.
Not sure if it's too late to fix it, but t should not be accepted as
a special pattern.  We could handle it like nil (i.e. pretend it's
a normal variable which then signals an error when we try to let-bind
it) or emit a warning.

> never", but raises an error when used  ("applies never" could make
> sense when the code is generated by a macro).

We currently don't have a special "fail" pattern which simply never
matches.  Of course, you can make one up (e.g. (guard nil)).  I think
making nil such a pattern would probably lead to more errors/confusion
than anything, since it's extremely rare to need such a pattern.

> I think I would consider to trivialize the semantic, merging the
> SELFQUOTING and 'VAL case.

We could drop the SELFQUOTING case, but I added it because it lets you
reduce the clutter of quoting, which tends to be fairly high in
pcase patterns.

> semantic of 'VAL as it is now, as it is perfectly clear.  To substitute
> the SELFQUOTING thing, we could allow something like ATOM - which can be
> any atomic expression that is not a symbol that can be bound - and make
> it simply an abbreviation for 'ATOM.

That's pretty much what SELFQUOTING is.  IF you think renaming it to
ATOM would help, then we could do that.

> (FWIW, unifying `ATOM and 'ATOM would IMHO also be worth it;

They should behave identically, yes.

> currently 'ATOM is compared always with
> `equal', whereby `ATOM is compared with `equal' for strings and `eq'
> else.

As explained the use of `eq' is supposed to be a pure optimization with
no semantics effect.  The fact that we accept floats and compare them
with `eq' is a plain bug.


        Stefan





  reply	other threads:[~2015-06-11 16:22 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-10 20:20 bug#20784: 25.0.50; pcase documentation on t and nil Artur Malabarba
2015-06-11  3:07 ` Stefan Monnier
2015-06-11 12:24   ` Artur Malabarba
2015-06-11 12:33     ` Michael Heerdegen
2015-06-11 15:23     ` Stefan Monnier
2015-06-11 13:18   ` Michael Heerdegen
2015-06-11 16:22     ` Stefan Monnier [this message]
2015-06-12 17:31       ` Michael Heerdegen
2015-06-16 16:43         ` Stefan Monnier
2015-06-11 16:34     ` Stefan Monnier
2015-06-12 17:36       ` Michael Heerdegen
2016-07-01  2:39         ` npostavs

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=jwva8w66xhp.fsf-monnier+emacsbugs@gnu.org \
    --to=monnier@iro.umontreal.ca \
    --cc=20784@debbugs.gnu.org \
    --cc=bruce.connor.am@gmail.com \
    --cc=michael_heerdegen@web.de \
    /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.