[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: How other pattern-matching lisps do [Was: Re: pcase ` meaning [Was:
From: |
Michael Heerdegen |
Subject: |
Re: How other pattern-matching lisps do [Was: Re: pcase ` meaning [Was: Re: Replace trivial pcase occurrences in the Emacs sources]] |
Date: |
Mon, 29 Oct 2018 00:16:18 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
"Garreau, Alexandre" <address@hidden> writes:
> As you can see, it also supports `not', and some facilities for OOP.
BTW, el-search supports `not'. AFAIK it would be trivial to add `not'
to pcase, but Stefan wants to wait for an idea of how to do so
efficiently.
> or `(assoc 1 alist-pattern)' (so “(match '((1 . 2)) ((assoc 1 x) x))”
> returns 2), to match content of an alist, or “property” for plists.
Oh, there are some emacs libraries you need to load to get corresponding
pcase macros. For example these:
-- (eieio &rest FIELDS)
Pcase patterns that match EIEIO object EXPVAL.
-- (seq &rest PATTERNS)
Build a `pcase' pattern that matches elements of SEQUENCE.
-- (rx &rest REGEXPS)
Build a `pcase' pattern matching `rx' REGEXPS in sexp form.
-- (cl-struct TYPE &rest FIELDS)
Pcase patterns that match cl-struct EXPVAL of type TYPE.
-- (radix-tree-leaf VPAT)
Build a `pcase' pattern that matches radix-tree leaf EXPVAL.
VPAT is a `pcase' pattern to extract the value.
-- (map &rest ARGS)
Build a `pcase' pattern matching map elements.
The last one supports matching alists conveniently.
> However something such as (pcase-defmacro list (&rest args) ``(,@args))
The normal backquote macro recursively handles also the backquotes and
unquotes that are meant for pcase, so you must avoid unwanted
processing. I would write it as
#+begin_src emacs-lisp
(pcase-defmacro list (&rest args)
`(,'\` ,(mapcar (lambda (thing) `(,'\, ,thing)) args)))
#+end_src
BTW, if you load "el-search-x.el", there is an `l' pattern defined, also
for matching lists, which also avoids ``' but has a completely different
semantics: it's more inspired by grep patterns, with the goal of
allowing to use very short input to find function definitions and such.
Michael.
- Re: Replace trivial pcase occurrences in the Emacs sources, (continued)
- Re: Replace trivial pcase occurrences in the Emacs sources, Garreau\, Alexandre, 2018/10/24
- 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 <=
- 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/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