[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: |
Mon, 21 Dec 2015 10:15:50 +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. ]]]
>
> > It matches anything (like a variable) but does not actually bind a
> variable.
>
> Alas, that's the half of the answer that I already knew.
> What I don't know is, how do you _write_ the use of _?
> That seemed self-contradictory in the text that was posted.
>
> Can someone show me some properly working examples of _ in pcase
> and say what they do?
Okay. This is the simplest use and it returns 'hello
(pcase 1
(_ 'hello))
It differs from a normal symbol because this:
(pcase 1
(a a))
evals to 1, while this
(pcase 1
(_ _))
errors with "void variable". That is `_' is not bound, unlike a. So `_'
is more than just convention.
Inside a list, though, it needs to be comma'd. So:
(pcase '(1 2 3)
(`(,a 2 3) 'hello))
(pcase '(1 2 3)
(`(,_ 2 3) 'hello))
both return `hello' (the former binding `a', the latter not binding
`_').
The question is how should this form behave.
(pcase '(1 2 3)
(`(_ 2 3) 'hello))
Currently, it returns `nil' because `_' matches the symbol `_' not
anything. Obviously, this is useful if you want to match the symbol
`_'. But I think it's unintuitive.
Even if everyone agrees it is wrong, if it is fixable, I do not know. I
suspect it's probably too late in the day for the emacs-25.
Phil
- Re: The poor state of documentation of pcase like things., (continued)
- 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, 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., 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 <=
- 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
- Re: The poor state of documentation of pcase like things., Michael Heerdegen, 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., Michael Heerdegen, 2015/12/24
- Re: The poor state of documentation of pcase like things., John Wiegley, 2015/12/24
- Re: The poor state of documentation of pcase like things., Michael Heerdegen, 2015/12/24
- 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., Eli Zaretskii, 2015/12/18
- Re: The poor state of documentation of pcase like things., Michael Heerdegen, 2015/12/19