[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pcase: Semantics of atom QPATS
From: |
Stefan Monnier |
Subject: |
Re: pcase: Semantics of atom QPATS |
Date: |
Mon, 11 Jun 2018 10:09:37 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> isn't it strange that the pattern '.7 matches .7, but `.7 causes an
> error when used?
Yes and no: the pattern '<anything> is defined to match using (equal
x '<anything>), no matter what. In contrast, ` behaves differently
depending on the type of the backquoted object and it only supports
a limited set of types (those documented in its docstring).
So it's normal for the two to behave differently.
> IMO the analogy to the list of self-quoting atoms (strings, keywords,
> integers - I'm all for that) is misguided here - something implicitly
> quoted in a backquoted pattern (i.e. something that is not unquoted)
> should behave like quoted with `'' (i.e. transformed into an `eq' test),
> everything else feels inconsistent.
[ It's an `equal` test we want, not `eq`. ]
The issue is rather that not all types might want an `equal` test.
E.g. we could accept patterns like
`#s(hash-table (data ,key1 ,val1))
Which is why I prefer signaling an error: it lets us extend the
semantics of ` without any fear of breaking backward compatibility.
But yes: it makes sense to extend pcase's ` pattern to accept floats and
match them with `equal` since it's easy and there doesn't seem to be
many other semantics to choose anyway.
Stefan
- pcase: Semantics of atom QPATS, Michael Heerdegen, 2018/06/09
- Re: pcase: Semantics of atom QPATS,
Stefan Monnier <=
- RE: pcase: Semantics of atom QPATS, Drew Adams, 2018/06/11
- Re: pcase: Semantics of atom QPATS, Michael Heerdegen, 2018/06/11
- Re: pcase: Semantics of atom QPATS, Michael Heerdegen, 2018/06/12
- Re: pcase: Semantics of atom QPATS, Stefan Monnier, 2018/06/13
- Re: pcase: Semantics of atom QPATS, Michael Heerdegen, 2018/06/16
- Re: pcase: Semantics of atom QPATS, Eli Zaretskii, 2018/06/16
- Re: pcase: Semantics of atom QPATS, Michael Heerdegen, 2018/06/16
- Re: pcase: Semantics of atom QPATS, Eli Zaretskii, 2018/06/16
- Re: pcase: Semantics of atom QPATS, Michael Heerdegen, 2018/06/17