After taking a look at the definition of defun
in byte-run.el
, it seems that the macro does some very interesting things regarding checking for the existence of a docstring.
First, it uses a declare
form to indicate that the third argument to the defun
is the docstring. It then checks whether the third argument is a string (which means it's a docstring), or actually a declare
form (which means there is no docstring).
If I understand correctly, this allows the user of a defun
to specify a docstring or to it out altogether.
Is this use of an optional argument considered unusual? Usually, for a function (foo a b &optional c d &rest rest)
, we'd enter a nil
for c
if we wanted to specify d
but not c
. I haven't seen other examples of arguments that can simply be "left out" like the docstring.