From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Tino Calancha Newsgroups: gmane.emacs.devel Subject: Re: Anaphoric macros: increase visibility Date: Sun, 15 Jan 2017 19:24:56 +0900 (JST) Message-ID: References: <87wpdyivvf.fsf@web.de> <87k29xqhqp.fsf@web.de> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset=US-ASCII X-Trace: blaine.gmane.org 1484475974 6083 195.159.176.226 (15 Jan 2017 10:26:14 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Sun, 15 Jan 2017 10:26:14 +0000 (UTC) User-Agent: Alpine 2.20 (DEB 67 2015-01-07) Cc: Mark Oteiza , Dmitri Paduchikh , Emacs developers , Tino Calancha To: Michael Heerdegen Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sun Jan 15 11:26:04 2017 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cSi0R-0007Sx-G4 for ged-emacs-devel@m.gmane.org; Sun, 15 Jan 2017 11:25:47 +0100 Original-Received: from localhost ([::1]:51002 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cSi0S-000510-SP for ged-emacs-devel@m.gmane.org; Sun, 15 Jan 2017 05:25:48 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49304) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cShzr-0004zi-7Q for emacs-devel@gnu.org; Sun, 15 Jan 2017 05:25:12 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cShzo-0008A2-0i for emacs-devel@gnu.org; Sun, 15 Jan 2017 05:25:11 -0500 Original-Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:36846) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1cShzn-00089O-QI for emacs-devel@gnu.org; Sun, 15 Jan 2017 05:25:07 -0500 Original-Received: by mail-pg0-x244.google.com with SMTP id 75so2762041pgf.3 for ; Sun, 15 Jan 2017 02:25:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:in-reply-to:message-id:references :user-agent:mime-version; bh=JMlVWH3TnqzG/0w1jposeOLJchPg7EVSse82Wd//m8k=; b=CPEN0MRAJsNkB4aLhJbVw4dV+xTvv1f7tyFI9Agmz06m0KViOdNfzOW8oQhHXOUDVU nq5CtpJ5S4aRiWXy35+7fNgcv3kpt9m2ExP17CBbd8Z1TY2KaPoWMc0X1MOrMgkxYQvW vtcFPKfftuXS+XiQ7/t1QbnptMKaeqOzvBI9LRXp6Bo2Kf7W/xVhMSDCqUo4+HmRzgti C0CCvC25bAdzdB4WBq/ZsGKnF1a6Okz022lKPEBtYPwrsrQH62VaSzEXntlaISLd0WeM WMo16Oxt/sf+3eMRLUIURZtIiJAG/VsdTYcGfdN9b11Xl+JqKrJIhza8zC9fmbnTA4zh RLpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:date:to:cc:subject:in-reply-to:message-id :references:user-agent:mime-version; bh=JMlVWH3TnqzG/0w1jposeOLJchPg7EVSse82Wd//m8k=; b=VjDZF6ZX9ye3u3ADat8KcfelvUm2abdGENnlI5f3Dqo7VxeQerDabs2X6f1KTx0E9l NQ5mvcrOZjGBTbl1ILRKCc0LSrGL80E5HGfQo3xhWtCie92nvw7udfahrU1LCNdooMfp RLtFnzq0WZ0Vw82pxBnVFMACkeT0REZn6iPJ6utqGdoH0W6AnNWQgZrI7UhJeBU+j3eZ zIwlV9rm4RqIRi1Vxr9c/3yBj6X9T6swgNoTTzmPPkSUwvNZizuYwhDqtZfMxUFi1rak 1y/KXF44GUMin1oAQAzPmSVqVYMUvwQkTs8Lxp13u0g+pNAqdR25MW/UhqfRv6KfPOR5 oaag== X-Gm-Message-State: AIkVDXJq9fANpeqYdhhFduVVJvF4ivPdDknSQ7YqNlfv6L5FDDzDVIMpmBaHy6tCvtFEbg== X-Received: by 10.84.168.129 with SMTP id f1mr30871572plb.7.1484475906817; Sun, 15 Jan 2017 02:25:06 -0800 (PST) Original-Received: from calancha-pc ([106.171.65.225]) by smtp.gmail.com with ESMTPSA id u14sm39904115pfg.18.2017.01.15.02.25.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 15 Jan 2017 02:25:06 -0800 (PST) X-Google-Original-From: Tino Calancha X-X-Sender: calancha@calancha-pc In-Reply-To: <87k29xqhqp.fsf@web.de> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::244 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.21 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" Xref: news.gmane.org gmane.emacs.devel:211310 Archived-At: Hi Michael, >I sometimes think that `if-let*' would be a better name for `if-let' >because bindings can refer (and naturally most of the time do) refer to other bindings. +1 >I also often think that `and-let' (or `and-let*' ...) would be a better name >for `when-let' (because the expressions for the bindings are `and'ed, >sot the whole thing feels more like `and' to me). I am in the middle of the 2 names: *) and-let* suggests me that the bindings are `and'ed **) but when-let* suggests me that the second argument is a list of expressions, i.e., not just a form. > (pcase-let ((`(,a ,b) '(1 2 3))) > (list a b)) > > ==> (1 2) > > although the pattern doesn't match. I can be bitten with that pitfall as well. >I think I would prefer something like > >#+begin_src emacs-lisp >(defmacro pwhen (pairs &rest body) > (declare (indent 1)) > `(pcase nil ((and ,@(mapcar (lambda (pair) (cons 'let pair)) pairs)) ,@body))) >#+end_src It might be useful. >I'm using `when-let' and `if-let' a lot, but I'm still not sure >in which direction we should develop this approach. >I think we should have an imagination of where the travel should >end before adding more *-let macros. A possible starting point is puting all together in subr-x.el after a heading ;;; Anaphoric macros. and perform the improvements in naming discussed in this thread: 1) Move `ibuffer-aif', `ibuffer-awhen' to subr-x.el and rename as `if-it', `when-it'. Add aliases to them `aif', `awhen'. 2) `if-let' --> `if-let*'. Add alias `if-let' for backward compatibility. 3) `when-let' --> `when-let*' (or `and-let*'). Add alias. Once they are all together is easier to see what macro is missing which could be useful. Tino