unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Okam via "Bug reports for GNU Emacs, the Swiss army knife of text editors" <bug-gnu-emacs@gnu.org>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: 47261@debbugs.gnu.org
Subject: bug#47261: Destructuring with Pcase without assigning values
Date: Sat, 17 Apr 2021 01:24:11 +0000	[thread overview]
Message-ID: <08c47ffc-58a3-d4f9-eae1-61a672d45b44@protonmail.com> (raw)
In-Reply-To: <jwvmtuy6crx.fsf-monnier+emacs@gnu.org>

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?






  reply	other threads:[~2021-04-17  1:24 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-19 13:47 bug#47261: Destructuring with Pcase without assigning values Okam via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-03-19 21:45 ` Stefan Monnier
2021-04-17  1:24   ` Okam via Bug reports for GNU Emacs, the Swiss army knife of text editors [this message]
2021-04-17  3:22     ` Stefan Monnier
     [not found]       ` <1dacded9-3e40-bc02-56c7-a157d739ffb7@protonmail.com>
2021-04-19 22:06         ` bug#47261: Fwd: " Earl Hyatt via Bug reports for GNU Emacs, the Swiss army knife of text editors
     [not found]         ` <jwveef84hcl.fsf-monnier+emacs@gnu.org>
     [not found]           ` <4925d1a5-4669-8290-e534-1662f13ca183@protonmail.com>
2021-04-19 22:10             ` Okam via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-06-24 18:36   ` Lars Ingebrigtsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=08c47ffc-58a3-d4f9-eae1-61a672d45b44@protonmail.com \
    --to=bug-gnu-emacs@gnu.org \
    --cc=47261@debbugs.gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=okamsn@protonmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).