unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Phil Sainty <psainty@orcon.net.nz>
To: Michael Heerdegen <michael_heerdegen@web.de>
Cc: daanturo <daanturo@gmail.com>, 49316@debbugs.gnu.org
Subject: bug#49316: Add apply-partially's right version
Date: Sun, 04 Jul 2021 02:13:53 +1200	[thread overview]
Message-ID: <8b10e4966ad9a1f621b5d9a6b069c7c7@webmail.orcon.net.nz> (raw)
In-Reply-To: <875yxsxfit.fsf@web.de>

On 2021-07-03 15:06, Michael Heerdegen wrote:
> A placeholder (e.g. the symbol `_' which should normally be unbound)
> stands for an argument that is used from the args provided in the 
> actual
> call:
> 
> (defalias 'my-list-with-some-elts
>   (applying-partially (list 0 _ 2 _ 4)))
> 
> (my-list-with-some-elts 'a 'b 'c 'd) ; => (0 a 2 b 4 c d)

I like the flexibility of the placeholder approach.  I'm not
sold on the extra parens used here -- I don't feel too strongly
about it, but it's inconsistent with how `apply-partially' is
called.

Similarly, being a macro is inconsistent, and eliminates the
ability to apply an arbitrary list of arguments to this, which
may be a useful thing to be able to do.  (It's syntactic sugar
though, so we don't *need* to account for all scenarios --
other use-cases can use the same approaches they do now.)

It's slightly problematic that any chosen placeholder might
be a valid argument to the function in question.  An underscore
feels as good a choice as any other, though, and provides the
mental association with the conventional use of an underscore
for unused arguments.  I suppose this issue is partly mitigated
if it does end up being a macro, as we can't then apply some
unknown list of args (which might happen to include the
placeholder value).

I think this is useful enough to implement regardless of that
last issue, and it could simply be documented that it shouldn't
be used in cases where the arguments are unknown, or where an
underscore (or whatever placeholder is chosen) is a valid arg.


-Phil






  parent reply	other threads:[~2021-07-03 14:13 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-01 12:40 bug#49316: Add apply-partially's right version daanturo
2021-07-01 13:11 ` Basil L. Contovounesios
2021-07-01 16:24   ` daanturo
2021-07-01 17:06     ` daanturo
2021-07-01 17:16       ` daanturo
2021-07-01 18:45       ` Eli Zaretskii
2021-07-02  2:49         ` daanturo
2021-07-03  7:03           ` Eli Zaretskii
2021-10-24  6:55             ` Stefan Kangas
2021-10-24 10:49               ` daanturo
2021-10-24 11:18                 ` Stefan Kangas
2021-10-24 12:13                   ` Eli Zaretskii
2021-10-24 13:47                     ` Lars Ingebrigtsen
2021-10-24 14:10                       ` Stefan Kangas
2021-10-24 14:28                       ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-10-25 12:50                         ` Lars Ingebrigtsen
2021-10-24 13:38               ` Lars Ingebrigtsen
2021-07-02 16:32         ` daanturo
2021-07-03  7:03           ` Eli Zaretskii
2021-07-01 22:34 ` Michael Heerdegen
2021-07-02  4:39   ` daanturo
2021-07-03  3:06     ` Michael Heerdegen
2021-07-03  6:17       ` daanturo
2021-07-03 14:13       ` Phil Sainty [this message]
2021-07-05  4:29         ` daanturo
2021-07-05 12:02           ` Phil Sainty
2021-07-06  4:33           ` Michael Heerdegen
2021-07-07 16:30             ` daanturo

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=8b10e4966ad9a1f621b5d9a6b069c7c7@webmail.orcon.net.nz \
    --to=psainty@orcon.net.nz \
    --cc=49316@debbugs.gnu.org \
    --cc=daanturo@gmail.com \
    --cc=michael_heerdegen@web.de \
    /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).