From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Artur Malabarba Newsgroups: gmane.emacs.devel Subject: Re: pcase-dolist Date: Wed, 8 Jul 2015 20:44:17 +0100 Message-ID: References: <87wpyaet7r.fsf@web.de> <87y4iqh7x0.fsf@web.de> Reply-To: bruce.connor.am@gmail.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Trace: ger.gmane.org 1436384666 12126 80.91.229.3 (8 Jul 2015 19:44:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 8 Jul 2015 19:44:26 +0000 (UTC) Cc: emacs-devel To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Wed Jul 08 21:44:26 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 1ZCvGb-0000z5-Bn for ged-emacs-devel@m.gmane.org; Wed, 08 Jul 2015 21:44:25 +0200 Original-Received: from localhost ([::1]:36655 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCvGa-0004yh-N9 for ged-emacs-devel@m.gmane.org; Wed, 08 Jul 2015 15:44:24 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:57579) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCvGW-0004yZ-Sq for emacs-devel@gnu.org; Wed, 08 Jul 2015 15:44:21 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCvGU-00065h-CY for emacs-devel@gnu.org; Wed, 08 Jul 2015 15:44:20 -0400 Original-Received: from mail-lb0-x230.google.com ([2a00:1450:4010:c04::230]:35930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCvGU-00065c-4v for emacs-devel@gnu.org; Wed, 08 Jul 2015 15:44:18 -0400 Original-Received: by lbbpo10 with SMTP id po10so62611495lbb.3 for ; Wed, 08 Jul 2015 12:44:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:reply-to:sender:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=8jKqvhmmY+Pui4XWxhSBqLmAPViAjFqDLRTja3K1VwU=; b=JAX4CiEcrxifZOEiO9xOkYFze5iHtoz/8P7Dq+4NI0GVj6QN2YkGxGgB554/yGLx1/ anwZhxGqQl6Q3QJ1uAsTDApY+OZV9vvcCcAVdPFjiNVCkHBuwg9fwrQyNDUUWsQQ9VCn qgRFB19EY8lGdeKHXF0DatsoZR5maB6SEjQBfIpi0oN60M5oM7ffLm+cMmm9LBAfAjd3 UQMxCLbgJYRzVwayI5FFPM7fVKR3lCaX+2JUKk6ummdRxdYb6CJzncf75bKR7Yi2iQBn T21RxQ6uTTcSGmQRmBkYqPIZE9CgoWAD7sLPzg8bqUyvBKh3xgvV3nsR6tviYi/LTUFB 0HaQ== X-Received: by 10.112.138.199 with SMTP id qs7mr11150249lbb.21.1436384657251; Wed, 08 Jul 2015 12:44:17 -0700 (PDT) Original-Received: by 10.25.214.133 with HTTP; Wed, 8 Jul 2015 12:44:17 -0700 (PDT) In-Reply-To: <87y4iqh7x0.fsf@web.de> X-Google-Sender-Auth: 0PLQSA43MZv39bRfdU1Bq9_vVu0 X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::230 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:187781 Archived-At: >> > Anyway, an idea that came to my mind more than once: `when-let', >> > `if-let' should really be `pcase-when-let' , `pcase-if-let'. They >> > would be much more useful than the plain versions I think. >> >> Yes, feel free to change them that way. > > Though, just changing them would break existing code (the current > versions are about boolean values, the pcase versions would be about > pattern matching). > > For example, now > > (if-let ((a (ignore))) a 17) ==> 17, > > but > > (pcase-if-let ((a (ignore))) a 17) ==> nil. Only if you make them like this. The idea of `(if-let ((a expr)) body)' is that evaluate `expr' and, if it is non-nil, bind it to a and run `body'. This doesn't exclude the possibility of `a' being a pcase pattern. Just make sure that the the check for nil expr is done as a separate thing, before the pattern matching. If you implement pcase-if-let the way you suggest above, isn't that just the same as pcase?