unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Tino Calancha <tino.calancha@gmail.com>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: Mark Oteiza <mvoteiza@udel.edu>,
	Dmitri Paduchikh <dpaduchikh@gmail.com>,
	Emacs developers <emacs-devel@gnu.org>,
	Tino Calancha <tino.calancha@gmail.com>
Subject: Re: Anaphoric macros: increase visibility
Date: Sun, 15 Jan 2017 19:24:56 +0900 (JST)	[thread overview]
Message-ID: <alpine.DEB.2.20.1701151921240.10958@calancha-pc> (raw)
In-Reply-To: <87k29xqhqp.fsf@web.de>


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



  parent reply	other threads:[~2017-01-15 10:24 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-13  8:39 Anaphoric macros: increase visibility Tino Calancha
2017-01-13 19:48 ` Michael Heerdegen
2017-01-14  2:30   ` Rolf Ade
2017-01-14  2:48     ` Rolf Ade
2017-01-14  3:03     ` Noam Postavsky
2017-01-14  4:13       ` Richard Copley
2017-01-14  5:27   ` Tino Calancha
2017-01-15  0:39     ` Michael Heerdegen
2017-01-15  2:24       ` On the naming/behavior of {if, when}-let (was Re: Anaphoric macros: increase visibility) Mark Oteiza
2017-01-15  2:26       ` Anaphoric macros: increase visibility Michael Heerdegen
2017-01-15 10:24       ` Tino Calancha [this message]
2017-01-15 15:32         ` Stefan Monnier
2017-01-16  2:44           ` Tino Calancha
2017-01-16  3:59             ` Stefan Monnier
2017-01-14  6:25   ` Dmitri Paduchikh
2017-01-14  7:56     ` Tino Calancha
2017-01-14 10:15       ` Dmitri Paduchikh
2017-01-15  0:29         ` Michael Heerdegen
2017-01-15  2:03           ` Dmitri Paduchikh
2017-01-15  2:16             ` Michael Heerdegen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.DEB.2.20.1701151921240.10958@calancha-pc \
    --to=tino.calancha@gmail.com \
    --cc=dpaduchikh@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=michael_heerdegen@web.de \
    --cc=mvoteiza@udel.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).