all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: <tomas@tuxteam.de>
To: emacs-devel@gnu.org
Subject: Re: Docs for &optional and &rest arguments together
Date: Thu, 31 Dec 2020 12:26:34 +0100	[thread overview]
Message-ID: <20201231112634.GA5158@tuxteam.de> (raw)
In-Reply-To: <AM0PR06MB6577D9BA42B23A9AE54D0EDC96D60@AM0PR06MB6577.eurprd06.prod.outlook.com>

[-- Attachment #1: Type: text/plain, Size: 1666 bytes --]

On Thu, Dec 31, 2020 at 07:55:26AM +0000, arthur miller wrote:
> I don't read it says both c and d are required when &rest is also used.

You just have to squint the other way .-)

They are not "required". They are provided -- in the call. It's just
that c is served first, d next, and all the rest (if any) goes to e:

  (defun foo (a b &optional c d &rest e))
    ...)

If called like

  (foo 42)
        => error (missing arg
  (foo 42 55)
        => a -> 42 b -> 55 c -> nil d -> nil e -> nil
  (foo 42 55 67)
        => a -> 42 b -> 55 c -> 67 d -> nil e -> nil
  (foo 42 55 67 92)
        => a -> 42 b -> 55 c -> 67 d -> 92 e -> nil
  (foo 42 55 67 92 117)
        => a -> 42 b -> 55 c -> 67 d -> 92 e -> (117)
  (foo 42 55 67 92 117 122)
        => a -> 42 b -> 55 c -> 67 d -> 92 e -> (117)
  (foo 42 55 67 92 117 122 131)
        => a -> 42 b -> 55 c -> 67 d -> 92 e -> (117 131)
  ...

Thing is, when calling the function you have /no way/ to express
which arg you are targeting [1]. This is what the doc is trying
to tell us with

  "If one or two more arguments are provided, c and d are
   bound to them respectively; any arguments after the first
   four are collected into a list and e is bound to that list."

As happens to Lars, to me this snippet seems to be as clear as
it gets. But there seems to be something you are stumbling over.
Since we can't see it, it's on you to open our eyes :)

How could that be put more clearly?

Cheers

[1] That's what "keyword arguments" are for. Emacs lisp
   doesn't come "natively" with keyword arguments, but
   this being a Lisp, they just can be "made" (cf. the
   CL library for one implementation).

 - t

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

  reply	other threads:[~2020-12-31 11:26 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-29 13:26 Docs for &optional and &rest arguments together Arthur Miller
2020-12-29 15:10 ` Adam Porter
2020-12-29 17:06   ` arthur miller
2021-01-01 14:33   ` Arthur Miller
2020-12-30  3:12 ` Lars Ingebrigtsen
2020-12-30 12:19   ` Arthur Miller
2020-12-30 12:54     ` Yuri Khan
2020-12-31  4:43     ` Lars Ingebrigtsen
2020-12-31  7:55       ` arthur miller
2020-12-31 11:26         ` tomas [this message]
2020-12-31 16:45           ` Drew Adams
2020-12-31 17:04             ` Drew Adams
2020-12-31 17:28             ` arthur miller
2020-12-31 18:19               ` Drew Adams
2020-12-31 20:01                 ` arthur miller
2020-12-31 20:27                   ` Drew Adams
2020-12-31 17:08           ` arthur miller
2020-12-31 17:30             ` Daniel Brooks
2020-12-31 19:53               ` arthur miller
2020-12-31 19:40             ` tomas
  -- strict thread matches above, loose matches on Subject: below --
2020-12-31 20:04 arthur miller
2020-12-31 20:35 ` tomas
2020-12-31 23:18   ` arthur miller

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=20201231112634.GA5158@tuxteam.de \
    --to=tomas@tuxteam.de \
    --cc=emacs-devel@gnu.org \
    /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.