[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pcase ` meaning
From: |
Yuri Khan |
Subject: |
Re: pcase ` meaning |
Date: |
Tue, 30 Oct 2018 23:05:08 +0700 |
On Tue, Oct 30, 2018 at 7:18 AM Garreau, Alexandre
<address@hidden> wrote:
> (pcase `(1 2 3) (`(1 2 3) t))
>
> look the same, as well as:
>
> (pcase `(a b c) (`(a b c) t))
>
> But not:
>
> (pcase `(1 2 3) (`(,a ,b ,c) (+ a b c)))
IMO you’re giving too much attention to “looking the same”.
You use identifiers a, b, and c in a pattern. The pattern matcher
needs to know which of these you meant as placeholders to bind, and
which as literal symbols to match against.
(let ((c 42))
(pcase `(a x 42) (`(a ,b ,(pred (equal c))) t)))
In an alternate world, you would color the parentheses, the spaces,
and the literal symbol “a” yellow, and say these are the things to
match literally. You would then color “b” and “c” white, and say these
are placeholders. You might even color something green and say these
are expressions whose values should be taken and matched.
In that same world, you could draw nested boxes instead of these
nested parentheses that make newbies so nervous about Lisp.
However, in this world, we only encode Unicode characters in our
source files, and add color only as an aid to understanding. So we use
various funny characters such as parentheses to denote nesting, and `
and , to denote color.
(Upthread, the idea of “holes” was mentioned. That is a very good
analogy, both for pcase and for quoting/antiquoting in general.)
- Re: How other pattern-matching lisps do [Was: Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources]], (continued)
- Re: How other pattern-matching lisps do [Was: Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources]], Michael Heerdegen, 2018/10/28
- Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources], Michael Heerdegen, 2018/10/28
- Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources], Garreau\, Alexandre, 2018/10/28
- Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources], Michael Heerdegen, 2018/10/28
- Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources], Garreau\, Alexandre, 2018/10/29
- Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources], Michael Heerdegen, 2018/10/29
- Re: pcase ` meaning, Garreau\, Alexandre, 2018/10/29
- Re: pcase ` meaning, Michael Heerdegen, 2018/10/29
- Re: pcase ` meaning, Garreau\, Alexandre, 2018/10/29
- Re: pcase ` meaning, Michael Heerdegen, 2018/10/29
- Re: pcase ` meaning,
Yuri Khan <=
- Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources], Clément Pit-Claudel, 2018/10/29
- Re: pcase ` meaning, Garreau\, Alexandre, 2018/10/29
- Re: pcase ` meaning, Stefan Monnier, 2018/10/30
- Re: pcase ` meaning, Garreau\, Alexandre, 2018/10/31
- Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/28
- Re: Replace trivial pcase occurrences in the Emacs sources, Michael Heerdegen, 2018/10/29
- What `case' have done you? [Was: Re: Replace trivial pcase occurrences in the Emacs sources], Garreau\, Alexandre, 2018/10/29
- Re: What `case' have done you? [Was: Re: Replace trivial pcase occurrences in the Emacs sources], Michael Heerdegen, 2018/10/29
- Re: Replace trivial pcase occurrences in the Emacs sources, Eli Zaretskii, 2018/10/30
- Re: Replace trivial pcase occurrences in the Emacs sources, Michael Heerdegen, 2018/10/30