bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

bug#71503: 30.0.50; pcase-lambda (with "and" and "guard") does not work


From: Philip Kaludercic
Subject: bug#71503: 30.0.50; pcase-lambda (with "and" and "guard") does not work as expected
Date: Sun, 21 Jul 2024 12:39:00 +0000

Stefan Monnier <monnier@iro.umontreal.ca> writes:

>>  (defmacro pcase-lambda (lambda-list &rest body)
>>    "Like `lambda' but allow each argument to be a pattern.
>> -I.e. accepts the usual &optional and &rest keywords, but every
>> -formal argument can be any pattern accepted by `pcase' (a mere
>> -variable name being but a special case of it)."
>> +I.e. accepts the usual &optional and &rest keywords, but every formal
>> +argument can be any pattern accepted by `pcase' (a mere variable name
>> +being but a special case of it).  Keep in mind that BODY is always
>> +evaluated, regardless of whether the argument-patterns match or not."
>>    (declare (doc-string 2) (indent defun)
>>             (debug (&define (&rest pcase-PAT) lambda-doc def-body)))
>>    (let* ((bindings ())
>
> I tend to call "any pattern accepted by `pcase'" a "Pcase pattern".
> More importantly, we should refer to `pcase-let` rather than to
> `pcase` here and we should likely use the term "destructuring (binding)".

Another confusing behaviour that we should document is that in

(let ((a nil))
  (funcall
   (pcase-lambda (a (and (guard a) b))
     (list a b))
   1 2))

I would expect that the (guard a) would use the nil binding from the
`let' form, but instead it is ignored and b is bound to 2.  I am not
sure if this is related to the "destructing" point or not.

>
>
>         Stefan
>

-- 
        Philip Kaludercic on peregrine





reply via email to

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