[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Pattern matching on match-string groups #elisp #question
From: |
Mattias Engdegård |
Subject: |
Re: Pattern matching on match-string groups #elisp #question |
Date: |
Thu, 25 Feb 2021 19:28:16 +0100 |
25 feb. 2021 kl. 16.32 skrev Stefan Monnier <monnier@iro.umontreal.ca>:
>> The same won't work with pcase-let, so it's either unsupported or a bug.
>
> I'd say it's a bug. The patch below would fix it. Mattias, WDYT?
Thank you, it looks like multiple bugs. The lack of (pred stringp) was of
course an oversight but unrelated to pcase-let, right?
> (let* ((rx--pcase-vars nil)
> (regexp (rx--to-expr (rx--pcase-transform (cons 'seq regexps)))))
> - `(and (pred (string-match ,regexp))
> + `(and (pred stringp)
> + (app (lambda (s) (string-match ,regexp s)) (pred identity))
It does seem to work, but why exactly do we need this monstrosity instead of
(pred (string-match ,regexp))? Is it because pcase-let throws away all `pred`
clauses somewhere? It makes sense to do so but I haven't found exactly where
this takes place in pcase.el yet...
Perhaps the assumption that non-binding clauses like `pred` (and what else,
`guard`?) are all side-effect free and can be thrown away in pcase-let[*]
should be documented? Not that I would have read it, of course...
I'll push a fix as soon as I understand the machinery a bit better, but right
now I'm wary of getting my fingers snapped off by the gears and knives.
- Pattern matching on match-string groups #elisp #question, Ag Ibragimov, 2021/02/25
- Re: Pattern matching on match-string groups #elisp #question, Basil L. Contovounesios, 2021/02/25
- Re: Pattern matching on match-string groups #elisp #question, Stefan Monnier, 2021/02/25
- Re: Pattern matching on match-string groups #elisp #question,
Mattias Engdegård <=
- Re: Pattern matching on match-string groups #elisp #question, Stefan Monnier, 2021/02/25
- Re: Pattern matching on match-string groups #elisp #question, Mattias Engdegård, 2021/02/26
- Re: Pattern matching on match-string groups #elisp #question, Stefan Monnier, 2021/02/26
- Re: Pattern matching on match-string groups #elisp #question, Mattias Engdegård, 2021/02/27
- Re: Pattern matching on match-string groups #elisp #question, Stefan Monnier, 2021/02/27
- Re: Pattern matching on match-string groups #elisp #question, Mattias Engdegård, 2021/02/27
- Re: Pattern matching on match-string groups #elisp #question, Stefan Monnier, 2021/02/27
- Re: Pattern matching on match-string groups #elisp #question, Mattias Engdegård, 2021/02/28
- Re: Pattern matching on match-string groups #elisp #question, Stefan Monnier, 2021/02/28