emacs-devel
[Top][All Lists]
Advanced

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

Re: pcase-dolist


From: Artur Malabarba
Subject: Re: pcase-dolist
Date: Wed, 8 Jul 2015 20:44:17 +0100

>> > Anyway, an idea that came to my mind more than once: `when-let',
>> > `if-let' should really be `pcase-when-let' , `pcase-if-let'.  They
>> > would be much more useful than the plain versions I think.
>>
>> Yes, feel free to change them that way.
>
> Though, just changing them would break existing code (the current
> versions are about boolean values, the pcase versions would be about
> pattern matching).
>
> For example, now
>
>   (if-let ((a (ignore))) a 17)       ==> 17,
>
> but
>
>   (pcase-if-let ((a (ignore))) a 17) ==> nil.

Only if you make them like this. The idea of `(if-let ((a expr))
body)' is that evaluate `expr' and, if it is non-nil, bind it to a and
run `body'. This doesn't exclude the possibility of `a' being a pcase
pattern. Just make sure that the the check for nil expr is done as a
separate thing, before the pattern matching.

If you implement pcase-if-let the way you suggest above, isn't that
just the same as pcase?



reply via email to

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