Subject: bug#49809: [PATCH] Add macro 'pcase-setq'

From: Stefan Monnier <[email-masked]>
Date: Thu, 05 Aug 2021 09:34:55 -0400

Michael Heerdegen [2021-08-05 03:02:03] wrote:
> Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of
> text editors" <[email-masked]> writes:
>
>> Looks good.
>
> How much trouble would it be to provide a `setf' variant?
>
> A problem could be any syntax that is used for both pcase patterns and
> place expressions I guess.

Adding support for (setf (pcase PAT) VAL) is very easy to do without any
change to pcase or gv machinery.

Adding support for (setf PAT VAL), is a bit harder (and introduces
a risk because of the potential overlap, tho this risk is small: gv
places are normally defined for "eliminators" whereas pcase patterns are
usually defined for "constructors"), but still fairly easy.

Mixing pcase patterns and gv places as in

    (setf `(,a . ,(aref V N)) EXP)

would be the most flexible option but I haven't thought much about how
hard it would be to implement, and I'm not sure it's worth the trouble.

        Stefan