[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the E
From: |
Michael Heerdegen |
Subject: |
Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources] |
Date: |
Sun, 28 Oct 2018 23:54:00 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
"Garreau, Alexandre" <address@hidden> writes:
> So know I understand why advocating for replacing case with pcase: pcase
> is not about pattern matching, it is just a correctly working case,
> except it only works for atoms, with an optional prevailing
> mini-language
If you look at the definition of the ``' pcase macro you see that it is
defined entirely in terms of the "things that only work for atoms" (it
uses `app' on car and cdr).
> Maybe that would make more sense if ` (and '?) were not part of pcase’s
> own mini-language, redefined by pcase, but if pcase actually truly
> eval’d its pattern, defining pred, guard, etc. as real functions,
> defined with a cl-letf, using lexical scoping so to prevailably define
> all these + user-defined patterns.
I think it would also be an interesting approach. You would
additionally need some magical thing that binds variables for the scope
of the current clause, however. That doesn't fit into that simple
approach. But not less than into pcase itself.
I wonder if it could be similarly efficient as pcase.
> It even more feel wrong that, this, doesn’t work, for no reason
Well, there is a reason: it is wrong ;-)
> #+BEGIN_SRC emacs-lisp
> (pcase [1 2]
> ([a b] (+ a b)))
> #+END_SRC
That should be
#+begin_src emacs-lisp
(pcase [1 2]
(`[,a ,b] (+ a b)))
#+end_src
I'm sure you would have been able to find that after less than a minute
when reading the pcase docstring.
Michael.
- Re: Replace trivial pcase occurrences in the Emacs sources, (continued)
- Re: Replace trivial pcase occurrences in the Emacs sources, Michael Heerdegen, 2018/10/27
- Re: Replace trivial pcase occurrences in the Emacs sources, Garreau\, Alexandre, 2018/10/27
- Re: Replace trivial pcase occurrences in the Emacs sources, Dmitry Gutov, 2018/10/27
- Re: Replace trivial pcase occurrences in the Emacs sources, Michael Heerdegen, 2018/10/27
- Re: Replace trivial pcase occurrences in the Emacs sources, Garreau\, Alexandre, 2018/10/27
- pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources], Garreau\, Alexandre, 2018/10/27
- How other pattern-matching lisps do [Was: Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources]], Garreau\, Alexandre, 2018/10/28
- Re: How other pattern-matching lisps do [Was: Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources]], Stefan Monnier, 2018/10/28
- Re: How other pattern-matching lisps do [Was: Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources]], Garreau\, Alexandre, 2018/10/28
- 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 <=
- 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, 2018/10/30
- Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources], Clément Pit-Claudel, 2018/10/29