GNU bug report logs -
#47261
Destructuring with Pcase without assigning values
Previous Next
Reported by: Okam <okamsn <at> protonmail.com>
Date: Fri, 19 Mar 2021 13:48:01 UTC
Severity: wishlist
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
On 3/19/21 5:45 PM, Stefan Monnier wrote:
> I massaged the code so that it now exports the following function:
>
> (defun pcase-compile-patterns (exp cases)
> "Compile the set of patterns in CASES.
> EXP is the expression that will be matched against the patterns.
> CASES is a list of elements (PAT . CODEGEN)
> where CODEGEN is a function that returns the code to use when
> PAT matches. That code has to be in the form of a cons cell.
>
> CODEGEN will be called with at least 2 arguments, VARVALS and COUNT.
> VARVALS is a list of elements of the form (VAR VAL . RESERVED) where VAR
> is a variable bound by the pattern and VAL is a duplicable expression
> that returns the value this variable should be bound to.
> If the pattern PAT uses `or', CODEGEN may be called multiple times,
> in which case it may want to generate the code differently to avoid
> a potential code explosion. For this reason the COUNT argument indicates
> how many time this CODEGEN is called."
>
> The `pcase` macro itself uses this function, so it should hopefully be
> "good enough", but let me know if it's causing you trouble.
>
>
> Stefan
>
This seems to work well for my use case. Thank you for making this change.
Are the variables always given in the order that they appear in the
pattern? If not, is finding elements of the form "(\, SYMBOL)" enough to
identify variables in a Pcase pattern?
This bug report was last modified 3 years and 2 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.