help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Functions with multiple optional arguments


From: Jean Louis
Subject: Re: Functions with multiple optional arguments
Date: Mon, 17 Oct 2022 07:05:14 +0300
User-agent: Mutt/2.2.7+37 (a90f69b) (2022-09-02)

* Heime via Users list for the GNU Emacs text editor <help-gnu-emacs@gnu.org> 
[2022-10-17 00:06]:

> Have been writing a function that has two optional arguments. It is
> turning out to be a difficult task in situations when one in missing
> an argument. Anybody has experience about this, as I have not seen
> much code with multiple optional arguments.

If argument is optional but required by your function, I use this method:

(defun my-fun (&optional title description)
  (let ((title (or title "Best Movie"))
        (description (or description "Description")))
    (message "%s: %s" title description)))

(my-fun)

-- 
Jean

Take action in Free Software Foundation campaigns:
https://www.fsf.org/campaigns

In support of Richard M. Stallman
https://stallmansupport.org/



reply via email to

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