[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Semantic of pcase `seq' and `map' patterns (was: pcase-setq)
From: |
Michael Heerdegen |
Subject: |
Semantic of pcase `seq' and `map' patterns (was: pcase-setq) |
Date: |
Mon, 12 Oct 2015 14:49:19 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/25.0.50 (gnu/linux) |
Nicolas Petton <address@hidden> writes:
> (seq-let (a b (c &rest others)) '(1 2 [3 4 5 6])
> (+ a b c))
After reading the doc of the `seq' pcase pattern:
--8<---------------cut here---------------start------------->8---
-- (seq &rest ARGS)
pcase pattern matching sequence elements.
Matches if the object is a sequence (list, string or vector), and
binds each element of ARGS to the corresponding element of the
sequence.
--8<---------------cut here---------------end--------------->8---
it was not obvious to me how this example would look like using pcase -
especially, what "are" the "ARGS"?
AFAIU the "ARGS" are just normal (pcase) patterns - they are not limited
to variables, and matching can fail for them as well even if the number
of sequence arguments would match.
I think the semantic would be better described like this:
--8<---------------cut here---------------start------------->8---
-- (seq &rest PATTERNS)
pcase pattern matching sequence elements.
Matches if the object is a sequence (list, string or vector), and
each PATTERN matches the corresponding element of the
sequence.
--8<---------------cut here---------------end--------------->8---
Does that make sense? Likewise `map', I guess.
Michael.
Re: pcase-setq (was: pcase-dolist), Nicolas Petton, 2015/10/15
- Semantic of pcase `seq' and `map' patterns (was: pcase-setq),
Michael Heerdegen <=
- Re: Semantic of pcase `seq' and `map' patterns, Michael Heerdegen, 2015/10/12
- Re: Semantic of pcase `seq' and `map' patterns, Nicolas Petton, 2015/10/12
- Re: Semantic of pcase `seq' and `map' patterns, Michael Heerdegen, 2015/10/12
- Re: Semantic of pcase `seq' and `map' patterns, Michael Heerdegen, 2015/10/17
- Re: Semantic of pcase `seq' and `map' patterns, Nicolas Petton, 2015/10/17
Re: Semantic of pcase `seq' and `map' patterns (was: pcase-setq), Nicolas Petton, 2015/10/15
Re: pcase-setq, Michael Heerdegen, 2015/10/15