[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: The poor state of documentation of pcase like things.
From: |
Phillip Lord |
Subject: |
Re: The poor state of documentation of pcase like things. |
Date: |
Fri, 18 Dec 2015 10:39:27 +0000 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Richard Stallman <address@hidden> writes:
> [[[ To any NSA and FBI agents reading my email: please consider ]]]
> [[[ whether defending the US Constitution against all enemies, ]]]
> [[[ foreign or domestic, requires you to follow Snowden's example. ]]]
>
> > There are many special UPatterns, and their variety makes this the hardest
> > aspect to master. Let's consider them one by one.
>
> > ## Underscore `_'
>
> > To match against anything whatsoever, no matter its type or value, use
> > underscore. Thus to match against a list containing anything at all at its
> > head, we'd use:
>
> > (pcase value
> > (`(_ 1 2)
> > (message "Matched a list of anything followed by (2 3)")))
>
> I don't follow this part. (_ 1 2) seems to be a QPattern.
> Is that right? So how is it that an element can be a UPattern?
I think the example is wrong. This....
(pcase '(3 1 2)
(`(_ 1 2)
(message "Matched a list of anything followed by (2 3)")))
prints nothing.
while this...
(pcase '(3 1 2)
(`(,_ 1 2)
(message "Matched a list of anything followed by (2 3)")))
prints the message (which should be "followed by (2 3)").
I am a bit surprised to find that _ needs , in these examples, and I
think that it's a bug.
I would anyway change it to:
(pcase '(3 1 2)
(`(,_ 1 2)
"Matched a list of anything followed by (1 2)"))
As I think it makes the point that `pcase' returns something, as opposed
to working by side effect. I think the example in the manual needs the
same change.
> It would help if some of the examples used symbols inside a QPattern,
> without comma, so we can see what that does.
A symbol IS a QPattern
(pcase '(a b c)
(`(a b ,x) x))
returns "c".
Phil
- Re: The poor state of documentation of pcase like things., (continued)
- Re: The poor state of documentation of pcase like things., Phillip Lord, 2015/12/18
- Re: The poor state of documentation of pcase like things., Marcin Borkowski, 2015/12/18
- Re: The poor state of documentation of pcase like things., John Wiegley, 2015/12/22
- Re: The poor state of documentation of pcase like things., Alan Mackenzie, 2015/12/17
- Re: The poor state of documentation of pcase like things., John Wiegley, 2015/12/17
- Re: The poor state of documentation of pcase like things., Eli Zaretskii, 2015/12/18
- Re: The poor state of documentation of pcase like things., Michael Heerdegen, 2015/12/19
- Re: The poor state of documentation of pcase like things., John Wiegley, 2015/12/22
Re: The poor state of documentation of pcase like things., John Wiegley, 2015/12/17
- Re: The poor state of documentation of pcase like things., Richard Stallman, 2015/12/17
- Re: The poor state of documentation of pcase like things.,
Phillip Lord <=
- Re: The poor state of documentation of pcase like things., Michael Heerdegen, 2015/12/19
- Re: The poor state of documentation of pcase like things., Phillip Lord, 2015/12/19
- Re: The poor state of documentation of pcase like things., Michael Heerdegen, 2015/12/19
- Re: The poor state of documentation of pcase like things., Phillip Lord, 2015/12/19
- Re: The poor state of documentation of pcase like things., Richard Stallman, 2015/12/20
- RE: The poor state of documentation of pcase like things., Phillip Lord, 2015/12/20
- Re: The poor state of documentation of pcase like things., Richard Stallman, 2015/12/21
- Re: The poor state of documentation of pcase like things., Phillip Lord, 2015/12/21
- Re: The poor state of documentation of pcase like things., John Wiegley, 2015/12/22
Re: The poor state of documentation of pcase like things., Michael Heerdegen, 2015/12/20