emacs-devel
[Top][All Lists]
Advanced

[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.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]