[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: function arguments optional default values
From: |
Stephen Berman |
Subject: |
Re: function arguments optional default values |
Date: |
Wed, 03 Jul 2024 23:51:28 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) |
On Wed, 03 Jul 2024 21:21:34 +0000 Heime <heimeborgia@protonmail.com> wrote:
> Does elisp support function arguments optional default values ?
The answer is in the Elisp manual (info "(elisp) Argument List"):
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.
Common Lisp note: Common Lisp allows the function to specify what
default value to use when an optional argument is omitted; Emacs
Lisp always uses ‘nil’. Emacs Lisp does not support ‘supplied-p’
variables that tell you whether an argument was explicitly passed.
Steve Berman