emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Docs for &optional and &rest arguments together


From: Arthur Miller
Subject: Re: Docs for &optional and &rest arguments together
Date: Wed, 30 Dec 2020 13:19:47 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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 via email to

[Prev in Thread] Current Thread [Next in Thread]