[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pcase-dolist
From: |
Tassilo Horn |
Subject: |
Re: pcase-dolist |
Date: |
Thu, 09 Jul 2015 08:05:46 +0200 |
User-agent: |
Gnus/5.130014 (Ma Gnus v0.14) Emacs/25.0.50 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
>> (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.
>
> So you'd want the above to signal an error in the case of:
>
> (pcase-let ((`(,w ,x) '(1 2 3)))
> (message "%s %s" w x))
>
> ?
Yes, if you want to pick the first two elements of a list with 2 or more
elements, you should use `(,w ,x . ,_). I see that the above is
slightly more convenient and concise but I'd value consistency more.
Bye,
Tassilo
- pcase-dolist, Michael Heerdegen, 2015/07/08
- Re: pcase-dolist, Stefan Monnier, 2015/07/08
- Re: pcase-dolist, Michael Heerdegen, 2015/07/08
- Re: pcase-dolist, Tassilo Horn, 2015/07/08
- Re: pcase-dolist, Stefan Monnier, 2015/07/08
- Re: pcase-dolist,
Tassilo Horn <=
- Re: pcase-dolist, Thierry Volpiatto, 2015/07/09
- Re: pcase-dolist, Tassilo Horn, 2015/07/09
- Re: pcase-dolist, Thierry Volpiatto, 2015/07/09
- Re: pcase-dolist, Tassilo Horn, 2015/07/09
- Re: pcase-dolist, Thierry Volpiatto, 2015/07/09
- Re: pcase-dolist, Stefan Monnier, 2015/07/09
- Re: pcase-dolist, Michael Heerdegen, 2015/07/09
- Re: pcase-dolist, Stefan Monnier, 2015/07/10
- Re: pcase-dolist, Tassilo Horn, 2015/07/10
- Re: pcase-dolist, Stefan Monnier, 2015/07/10