all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Arthur Miller <arthur.miller@live.com>
To: Lars Ingebrigtsen <larsi@gnus.org>
Cc: emacs-devel@gnu.org
Subject: Re: Docs for &optional and &rest arguments together
Date: Wed, 30 Dec 2020 13:19:47 +0100	[thread overview]
Message-ID: <AM0PR06MB6577D086DD918C31A82C283F96D70@AM0PR06MB6577.eurprd06.prod.outlook.com> (raw)
In-Reply-To: <87o8icq958.fsf@gnus.org> (Lars Ingebrigtsen's message of "Wed, 30 Dec 2020 04:12:51 +0100")

Lars Ingebrigtsen <larsi@gnus.org> writes:

> Arthur Miller <arthur.miller@live.com> writes:
>
>> (required-vars…
>>  [&optional [optional-vars…]]
>>  [&rest [rest-var]])
>>
>> But when I use it, I still have to pass a nil for the "optional"
>> argument, which I think is also not so strange either, otherwise how
>> will Emacs now where "optional" argument list ends and where "rest"
>> argument list starts? No?
>
> Right.
>
>> If actual arguments for the optional and rest variables are omitted,
>> then they always default to nil."
>>
>> https://www.gnu.org/software/emacs/manual/html_node/elisp/Argument-List.html
>>
>> I get the impression that I actually can omit the optional argument(s)
>> even when followed by the &rest keyword.
>
> The paragraph just below this one, though, describes in detail what
> happens with a mixed &optional and &rest argument list, so that's not my
> impression when reading that node.

"A call to the function requires one actual argument for each of the
required-vars. There may be actual arguments for zero or more of the
optional-vars, and there cannot be any actual arguments beyond that
unless the lambda list uses &rest. In that case, there may be any number
of extra actual arguments."

"If actual arguments for the optional and rest variables are omitted,
then they always default to nil. There is no way for the function to
distinguish between an explicit argument of nil and an omitted
argument. However, the body of the function is free to consider nil an
abbreviation for some other meaningful value. This is what substring
does; nil as the third argument to substring means to use the length of
the string supplied."

Which part of the doc does it say that &optional argument when
used together with &rest, makes &optional argument mandatory, i.e. can
not be ommitted when calling a function or macro?



  reply	other threads:[~2020-12-30 12:19 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 [this message]
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
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=AM0PR06MB6577D086DD918C31A82C283F96D70@AM0PR06MB6577.eurprd06.prod.outlook.com \
    --to=arthur.miller@live.com \
    --cc=emacs-devel@gnu.org \
    --cc=larsi@gnus.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.