emacs-devel
[Top][All Lists]
Advanced

[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




reply via email to

[Prev in Thread] Current Thread [Next in Thread]