GNU bug report logs - #49316
Add apply-partially's right version

Previous Next

Package: emacs;

Reported by: daanturo <daanturo <at> gmail.com>

Date: Thu, 1 Jul 2021 12:41:02 UTC

Severity: normal

Tags: patch, wontfix

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

Full log


Message #49 received at 49316 <at> debbugs.gnu.org (full text, mbox):

From: Phil Sainty <psainty <at> orcon.net.nz>
To: Michael Heerdegen <michael_heerdegen <at> web.de>
Cc: daanturo <daanturo <at> gmail.com>, 49316 <at> debbugs.gnu.org
Subject: Re: bug#49316: Add apply-partially's right version
Date: Sun, 04 Jul 2021 02:13:53 +1200
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





This bug report was last modified 3 years and 211 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.