all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Phil Sainty <psainty@orcon.net.nz>, Pip Cet <pipcet@gmail.com>
Cc: Stefan Kangas <stefan@marxist.se>, 40968@debbugs.gnu.org
Subject: bug#40968: 28.0.50; (apply nil)
Date: Wed, 6 May 2020 14:35:41 -0700 (PDT)	[thread overview]
Message-ID: <afae9654-c31e-4c7e-b4e8-da394e84a719@default> (raw)
In-Reply-To: <c91ab335234cca0a2614ad8e3b0c65aa@webmail.orcon.net.nz>

> To my mind the nicest change would be to handle the two error cases,
> and keep everything else the same.
> 
> 1. (apply nil) would signal an error.
> 2. (apply FUNC) would be equivalent to funcall, rather than signalling
>     an error, when (functionp FUNC) -- or perhaps just (not (consp
>     FUNC)).
> 3. (apply LIST) would remain equivalent to (apply (car LIST) (cdr
>     LIST))
> 
> I don't feel strongly about #2.  It seems like a nice enhancement to
> me,
> but if others feel that would be cause problems then I wouldn't argue.
> Existing uses of that in the wild are obviously signalling errors at
> present, so offhand it doesn't seem to me like a dangerous change, and
> it would match the existing signature.
> 
> #3 just seems like the only useful thing that apply could possibly do
> with a single list argument, so I'd definitely keep that.
> 
> #2 and #3 are surely both convenient for generated code which doesn't
> know how many arguments it's going to be dealing with.
> 
> I would still use (FUNCTION &optional ARGS) as the signature, and just
> document what happens when FUNCTION is actually a list.

What's wrong with doing what Common Lisp does
(apparently, per the doc'd signature)?

(apply FUNCTION first-arg &rest other-args)

The first arg to `apply' is required, and
must be a function.

The second arg to `apply' is required.
Any arg after the second is optional.

The last arg to `apply' must be a list.
(This is true even if it is the second arg.)
It can be nil.

* If the last arg is the second arg, then its
  elements are the args passed to FUNCTION.
  (If it is the empty list then FUNCTION must
  be nullary.)

* If the last arg is not the second arg, then
  its elements are the Nth args for FUNCTION,
  where N = 1+ the element index.  FUNCTION
  must be able to accept M args, where M = 1+
  the number of elements in the last arg.

"Must" means an error is raised if not so.


(apply)          => error
(apply ANYTHING) => error

(apply FUNCTION '(x)   ) => (funcall FUNCTION x)
 ; last arg: singleton list of args

(apply FUNCTION   x  ()) => (funcall FUNCTION x)
 ; first arg: x
 ; last arg: empty list of other args

(apply FUNCTION  ()    ) => (funcall FUNCTION)
 ; last arg: empty list of args

(apply FUNCTION  ()  ()) => (funcall FUNCTION nil)
 ; first arg nil
 ; last arg: empty list of other args





  reply	other threads:[~2020-05-06 21:35 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-29 18:26 bug#40968: 28.0.50; (apply nil) Pip Cet
2020-04-29 18:35 ` Pip Cet
2020-05-06  1:51 ` Stefan Kangas
2020-05-06  7:26   ` Pip Cet
2020-05-06 11:24     ` Stefan Kangas
2020-05-06 11:49       ` Pip Cet
2020-05-06 13:02         ` Stefan Kangas
2020-05-06 13:55           ` Pip Cet
2020-05-06 15:28             ` Stefan Kangas
2020-05-06 18:06               ` Pip Cet
2020-05-06 19:26                 ` Drew Adams
2020-05-06 14:03           ` Eli Zaretskii
2020-05-06 17:54             ` Pip Cet
2020-05-06 18:09               ` Eli Zaretskii
2020-05-06 18:00           ` Drew Adams
2020-05-06 18:28             ` Noam Postavsky
2020-05-06 19:17               ` Drew Adams
2020-05-06 19:21                 ` Pip Cet
2020-05-06 19:28                   ` Drew Adams
2020-05-07  2:27                     ` Eli Zaretskii
2020-05-06 17:46         ` Drew Adams
2020-05-06 20:32         ` Phil Sainty
2020-05-06 21:35           ` Drew Adams [this message]
2020-09-29  3:00     ` Stefan Monnier
2020-05-06 10:18 ` Mattias Engdegård
2020-05-06 10:45   ` Eli Zaretskii
2020-05-06 10:57     ` Andreas Schwab
2020-05-06 11:25   ` Pip Cet
2020-05-06 11:49     ` Mattias Engdegård
2020-05-06 18:42 ` Mattias Engdegård
2020-05-07  6:53   ` Pip Cet
2020-05-07  9:11     ` Mattias Engdegård
2020-05-07 11:54       ` Noam Postavsky
2020-05-07 11:58         ` Pip Cet
2020-05-07 12:20           ` Noam Postavsky
2020-05-07 13:53         ` Mattias Engdegård
2020-06-02  7:36           ` Pip Cet
2020-06-02 16:32             ` Drew Adams
2020-06-02 16:43               ` Eli Zaretskii
2020-06-02 16:36             ` Eli Zaretskii
2020-09-27 15:01             ` Lars Ingebrigtsen
2020-09-27 19:28               ` Drew Adams
     [not found] <<CC40D602-5027-40A7-9BAB-1AADC9E4BDAE@acm.org>
     [not found] ` <<CAOqdjBfj6AExvem5WWLfMiw4fEsY-xUUmosV+fj9CaPgWM16ag@mail.gmail.com>
     [not found]   ` <<ECEC9424-919F-4364-9294-381C8751921A@acm.org>
     [not found]     ` <<874kssm04d.fsf@gmail.com>
     [not found]       ` <<6ADF0807-7EBD-4054-8579-4D9AD3065D51@acm.org>
     [not found]         ` <<CAOqdjBdQne3RFTjg4hej40L5aeBx6vbGp6nXKx2TwPkLPf5NPw@mail.gmail.com>
     [not found]           ` <<fabfb1fd-4da1-4e72-90c9-333532011a48@default>
     [not found]             ` <<83pnahctad.fsf@gnu.org>
2020-06-02 17:10               ` Drew Adams
2020-06-02 18:41                 ` Pip Cet

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

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

  git send-email \
    --in-reply-to=afae9654-c31e-4c7e-b4e8-da394e84a719@default \
    --to=drew.adams@oracle.com \
    --cc=40968@debbugs.gnu.org \
    --cc=pipcet@gmail.com \
    --cc=psainty@orcon.net.nz \
    --cc=stefan@marxist.se \
    /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 external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.