[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: |
Garreau\, Alexandre |
Subject: |
Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources] |
Date: |
Mon, 29 Oct 2018 00:09:36 +0100 |
User-agent: |
Gnus (5.13), GNU Emacs 25.1.1 (i686-pc-linux-gnu, GTK+ Version 3.22.11) of 2017-09-15, modified by Debian |
Le 28/10/2018 à 23h54, Michael Heerdegen a écrit :
> "Garreau, Alexandre" <address@hidden> writes:
>> 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.
“(var name)”, as does racket and some common-lisp match/unify
implementations. And so to integrate with “`”: “,(var name)” doesn’t
disturb me, it is okay: will bind “name” to something, pretty
straightforward.
> I wonder if it could be similarly efficient as pcase.
I’m almost sure it wouldn’t, or otherwise it would be awfully complex.
But, if there were something to replace ` while not being
counter-intuitive, I could live with ` not being efficient, but intuitive.
>> 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.
I found that before sending the mail. But what I said I feel wrong, is
that this is wrong, after current pcase rules. While it works for guile
and racket match, as well as several common lisp match, with only some
common-lisp match such as cl-match and optima as exceptions.
What is confusing is [] can’t serve for the pattern language, so it
feels wrong to disallow using it for pattern matching. Beside lisp, all
pattern matching language make their feature serve one purpose: the
pattern look like what the data should be. adding “`” and “,” destroy
this feature, because the pattern no longer looks like what is matched.
- Re: Replace trivial pcase occurrences in the Emacs sources, (continued)
- 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, 2018/10/28
- Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources],
Garreau\, Alexandre <=
- 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
- Re: pcase ` meaning, Garreau\, Alexandre, 2018/10/29