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 14:19:03 +0200 Message-ID: <87a8v5bk20.fsf@gmail.com> References: <87wpyaet7r.fsf@web.de> <87y4iqh7x0.fsf@web.de> <87oajmld49.fsf@gnu.org> <87oajlyif9.fsf@gnu.org> <874mldwt7y.fsf@gmail.com> <878uapy6r9.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1436444399 1901 80.91.229.3 (9 Jul 2015 12:19:59 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 9 Jul 2015 12:19:59 +0000 (UTC) Cc: emacs-devel@gnu.org To: Tassilo Horn Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Jul 09 14:19:44 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 1ZDAnn-0004ii-SI for ged-emacs-devel@m.gmane.org; Thu, 09 Jul 2015 14:19:44 +0200 Original-Received: from localhost ([::1]:39431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDAnm-0000d0-Tc for ged-emacs-devel@m.gmane.org; Thu, 09 Jul 2015 08:19:42 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:51829) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDAnL-0000Yp-4P for emacs-devel@gnu.org; Thu, 09 Jul 2015 08:19:15 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZDAnH-0005UP-IZ for emacs-devel@gnu.org; Thu, 09 Jul 2015 08:19:15 -0400 Original-Received: from mail-wg0-x22f.google.com ([2a00:1450:400c:c00::22f]:32839) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZDAnH-0005Tx-Av; Thu, 09 Jul 2015 08:19:11 -0400 Original-Received: by wgck11 with SMTP id k11so222108282wgc.0; Thu, 09 Jul 2015 05:19:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=references:from:to:cc:subject:in-reply-to:date:message-id :mime-version:content-type; bh=7SpZC79ixrbf1cuyumlMAXCOk8Tsw1r+Mmrx0X45iYI=; b=cvx4JIxN/eNldLtw20Ao/pey1jHw3GkjlviycKgFYFPJ6Jj9F//8jLzH49bzNUwV9B Uc0Ns0zcXRxtzsXfjPJHB2NB77nlOi6NQCyJ/b/P5Zj4hPfhybj/oW0nJLQw/+2vfttj sVkoI8w3RkXJM2UyvYPBkcIsPf5QOFXAbCTHBRlsepCl88YVl+R+ce0G8Kkf4m1j1FPe qL67iWp/uatHjVnTQbC71tdLZQn4lSrVdbGqxSmb0zB75I0/jleYEQQ0lnkTpmA3IVph V+Svpib+nHqkbDVlXWKiopq7wH4ZX4CZMJGBaICtevO1DFRFbnLhUWsT8a0vK19zwvCe OdXA== X-Received: by 10.180.87.199 with SMTP id ba7mr88425635wib.81.1436444349309; Thu, 09 Jul 2015 05:19:09 -0700 (PDT) Original-Received: from dell-14z ([37.161.129.93]) by smtp.gmail.com with ESMTPSA id da5sm1696017wib.6.2015.07.09.05.19.07 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Thu, 09 Jul 2015 05:19:08 -0700 (PDT) In-reply-to: <878uapy6r9.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c00::22f 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:187788 Archived-At: Tassilo Horn writes: > Thierry Volpiatto 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