According to Functions at GigaMonkeys, Common Lisp supports additional positional parameters through &optional, and the default value can be set arbitrarily.
The default value is nil.
(defun function (mandatory-argument &optional optional-argument) ... )
and the default value can be set arbitrarily
(defun function (mandatory-argument &optional (optional-argument "")) ....)
Is there a way to distinguish between cases where an optional parameter has a default value explicitly passed to vs without a value?
EDIT: Apparently, the linked page explains this.
It is sometimes useful to know if the value of the optional argument was provided by the caller or is the default value. Rather than writing code to check if the parameter value is the default (this does not work if the caller explicitly pass the default value), you can add another variable name to the parameter specifier after the default expression. This variable will be bound to true if the calling argument for this parameter and NIL otherwise. By convention, these variables are usually called the same as the actual parameter, with msgstr "-pressor-p" at the end. For example:
(defun foo (a b &optional (c 3 c-supplied-p))
(list a b c c-supplied-p))
source
share