[Top][All Lists]

[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 11:55:29 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Tassilo Horn <address@hidden> writes:

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

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.

Of course one can use `cl-multiple-value-bind' instead in such situation.

Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997 

reply via email to

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