GNU bug report logs -
#71503
30.0.50; pcase-lambda (with "and" and "guard") does not work as expected
Previous Next
Reported by: Mekeor Melire <mekeor <at> posteo.de>
Date: Wed, 12 Jun 2024 08:42:01 UTC
Severity: normal
Found in version 30.0.50
Done: Philip Kaludercic <philipk <at> posteo.net>
Bug is archived. No further changes may be made.
Full log
View this message in rfc822 format
Stefan Monnier <monnier <at> 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
This bug report was last modified 287 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.