Subject: Re: bug#49316: Add apply-partially's right version

From: Phil Sainty <[email-masked]>
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