[Top][All Lists]

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

Re: pcase-dolist

From: Tassilo Horn
Subject: Re: pcase-dolist
Date: Wed, 08 Jul 2015 20:26:30 +0200
User-agent: Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux)

Michael Heerdegen <address@hidden> writes:

>> It could also skip those elements that don't match
> That's what I had expected without thinking too much about it.  But I
> agree that we would end with something different.

I also think that `pcase-let' and `pcase-dolist' are pretty confusing.
For example,

  (pcase-let ((`(,w ,x ,y ,z) '(1 2 3)))
    (message "%s %s %s %s" w x y z))

prints "1 2 3 nil" although the pattern when used in `pcase' wouldn't
match that list but only 4-element lists.  So a pcase pattern has
different semantics depending on whether it is used in `pcase' or
`pcase-let' or `pcase-dolist' which doesn't feel right.

I'd prefer if `pcase-let' would signal an error if some pattern doesn't
match.  Same for `pcase-dolist' with its current semantics.  IMHO, the
code above clearly says that the programmer expected to destructure
4-element lists so an error signaling that the expectation is wrong
sounds right.

>> > 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).

So why not have both?


reply via email to

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