From: Stefan Monnier <monnier@iro.umontreal.ca>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: jixiuf <jixiuf@qq.com>, 45619@debbugs.gnu.org
Subject: bug#45619: 28.0.50; pcase-let on MacOS doesn't work
Date: Thu, 07 Jan 2021 10:19:46 -0500 [thread overview]
Message-ID: <jwveeiwpypx.fsf-monnier+emacs@gnu.org> (raw)
In-Reply-To: <87v9c99duj.fsf@web.de> (Michael Heerdegen's message of "Thu, 07 Jan 2021 12:38:12 +0100")
>> Hmm... so-called "non-linear patterns". We should emit a warning when the
>> same var is used twice in a pattern, indeed, to avoid surprises.
>
> Not sure if we speak about the same case. I spoke about this: I caught
> myself trying something like that:
>
> (defvar thing-tag 'a-thing)
>
> (let ((my-thing (cons thing-tag '(thing-contents...))))
> (pcase my-thing
> (`(,thing-tag . ,contents) (do-something-with contents))))
Ah, indeed it's not the same thing as non-linear patterns.
An example of a non-linear pattern could be:
(pcase foo
(`(,a . ,a)
(message "foo is a pair with car equal to cdr"))
...)
For your use case, you can write:
(pcase my-thing
(`(,(pred (equal thing-tag)) . ,contents) (do-something-with contents))))
> Something diametral to my previous suggestion, I don't know if it would
> be appropriate: You know scheme syntax rules and it's concept of
> hygiene? Similarly in `pcase' we could silently transform any
> appearance of a SYMBOL with a fresh uninterned symbol. While that would
> not change the behavior for the common use cases, it would be clear that
> bindings created by pcase would never interfere in any way with already
> existing bindings of any kind.
I know about macro hygiene, but what you describe is a mechanism
to get a particular semantics (a form a hygiene, typically), but I don't
understand what semantics you're trying to get.
Could you give some examples of problems you'd like to avoid this way?
> Being able to change the binding of a special variable sounds nice, but
> I think that could also happen by accident, right?
As I said, I think we should declare this is unsupported and try to emit
a warning what we detect such a thing (tho we should still support
corner cases like
(pcase-let
(((,foo . ,bar) (blabla))
(default-directory (blibli)))
...)
Stefan
next prev parent reply other threads:[~2021-01-07 15:19 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-03 7:59 bug#45619: 28.0.50; pcase-let on MacOS doesn't work jixiuf
2021-01-04 12:44 ` Michael Heerdegen
2021-01-04 15:41 ` Drew Adams
2021-01-04 17:41 ` Stefan Monnier
2021-01-04 19:50 ` Michael Heerdegen
2021-01-04 20:37 ` Stefan Monnier
2021-01-04 22:08 ` Michael Heerdegen
2021-01-05 2:06 ` Stefan Monnier
2021-01-07 11:38 ` Michael Heerdegen
2021-01-07 15:19 ` Stefan Monnier [this message]
2021-01-08 20:05 ` Michael Heerdegen
2021-01-08 22:13 ` Stefan Monnier
2022-02-12 7:46 ` Lars Ingebrigtsen
2022-02-12 14:56 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-12 16:30 ` Lars Ingebrigtsen
2022-02-12 17:10 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-02-12 17:21 ` Lars Ingebrigtsen
2022-02-12 22:33 ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
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=jwveeiwpypx.fsf-monnier+emacs@gnu.org \
--to=monnier@iro.umontreal.ca \
--cc=45619@debbugs.gnu.org \
--cc=jixiuf@qq.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 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).