[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: pcase-dolist
From: |
Thierry Volpiatto |
Subject: |
Re: pcase-dolist |
Date: |
Thu, 09 Jul 2015 14:19:03 +0200 |
Tassilo Horn <address@hidden> writes:
> Thierry Volpiatto <address@hidden> writes:
>
>>>> 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.
>>
>> This would be a regression IMHO, what if you want to do e.g:
>>
>> (pcase-let ((`(,a ,b) (file-attributes "foo")))
>> (list a b))
>>
>> It would be inconvenient to have to bind the 10 unused remaining
>> elements.
>
> As I've said, you can use cdr-matching with a don't-care-pattern, e.g.,
>
> (pcase-let ((`(,a ,b . ,_) (file-attributes "~/.emacs")))
> (list a b))
>
> which clearly states that you know that the list returned by
> `file-attributes' has more than two elements but you are only interested
> in the first two.
Ah! Ok so the dont-care-pattern handle all the remaining elements.
So yes like this the intention is clearer.
Thanks.
--
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997
- 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, 2015/07/09
- Re: pcase-dolist, Thierry Volpiatto, 2015/07/09
- Re: pcase-dolist, Tassilo Horn, 2015/07/09
- Re: pcase-dolist,
Thierry Volpiatto <=
- 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
- Re: pcase-dolist, Artur Malabarba, 2015/07/08
- Re: pcase-dolist, Michael Heerdegen, 2015/07/08