From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Thierry Volpiatto Newsgroups: gmane.emacs.devel Subject: Re: pcase-dolist Date: Thu, 09 Jul 2015 11:55:29 +0200 Organization: Emacs Helm Message-ID: <874mldwt7y.fsf@gmail.com> References: <87wpyaet7r.fsf@web.de> <87y4iqh7x0.fsf@web.de> <87oajmld49.fsf@gnu.org> <87oajlyif9.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1436435778 24929 80.91.229.3 (9 Jul 2015 09:56:18 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 9 Jul 2015 09:56:18 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 09 11:56:08 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1ZD8Yp-0006l9-2Z for ged-emacs-devel@m.gmane.org; Thu, 09 Jul 2015 11:56:07 +0200 Original-Received: from localhost ([::1]:38741 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZD8Yo-0005om-95 for ged-emacs-devel@m.gmane.org; Thu, 09 Jul 2015 05:56:06 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:34366) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZD8YZ-0005oY-5M for emacs-devel@gnu.org; Thu, 09 Jul 2015 05:55:52 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZD8YT-00083v-4a for emacs-devel@gnu.org; Thu, 09 Jul 2015 05:55:51 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:53984) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZD8YS-00082u-8y for emacs-devel@gnu.org; Thu, 09 Jul 2015 05:55:44 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1ZD8YQ-0006VQ-Rp for emacs-devel@gnu.org; Thu, 09 Jul 2015 11:55:42 +0200 Original-Received: from 37.161.129.93 ([37.161.129.93]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 09 Jul 2015 11:55:42 +0200 Original-Received: from thierry.volpiatto by 37.161.129.93 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Thu, 09 Jul 2015 11:55:42 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 39 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 37.161.129.93 User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) Cancel-Lock: sha1:dXe7BZAOqswwIGgJpPiXjcWrjlY= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:187786 Archived-At: Tassilo Horn writes: > Stefan Monnier 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. -- Thierry Get my Gnupg key: gpg --keyserver pgp.mit.edu --recv-keys 59F29997