all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Drew Adams <drew.adams@oracle.com>
To: Jean Louis <bugs@gnu.support>, Heime <heimeborgia@protonmail.com>
Cc: Heime via Users list for the GNU Emacs text editor
	<help-gnu-emacs@gnu.org>
Subject: RE: [External] : Re: function arguments optional default values
Date: Sat, 6 Jul 2024 15:03:52 +0000	[thread overview]
Message-ID: <SJ0PR10MB54887FCD2206E402BF2FD8FFF3D82@SJ0PR10MB5488.namprd10.prod.outlook.com> (raw)
In-Reply-To: <Zok73-aTMoKul4w0@lco2>

> > Does elisp support function arguments optional default values ?
> 
> I solve that problem with following:
> 
> (defun my-function (arg &optional other-arg)
>   (let* ((other-arg (or other-arg my-default)))
>     other-arg))

Simpler - no reason for another binding,
just change the value (it's a local var).

(defun my-function (arg &optional other-arg)
  (setq other-arg  (or other-arg my-default))
  ...)

or

(defun my-function (arg &optional other-arg)
  (unless other-arg (setq other-arg  my-default))
  ...)


  reply	other threads:[~2024-07-06 15:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-03 21:21 function arguments optional default values Heime
2024-07-03 21:51 ` Stephen Berman
2024-07-03 21:56   ` Heime
2024-07-03 22:04     ` Stephen Berman
2024-07-03 22:24       ` Stephen Berman
2024-07-06 12:43 ` Jean Louis
2024-07-06 15:03   ` Drew Adams [this message]
2024-07-06 15:55     ` [External] : " Stefan Monnier via Users list for the GNU Emacs text editor
2024-07-06 16:06       ` Drew Adams
2024-07-06 19:04         ` Stefan Monnier via Users list for the GNU Emacs text editor
2024-07-06 21:48       ` Heime

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=SJ0PR10MB54887FCD2206E402BF2FD8FFF3D82@SJ0PR10MB5488.namprd10.prod.outlook.com \
    --to=drew.adams@oracle.com \
    --cc=bugs@gnu.support \
    --cc=heimeborgia@protonmail.com \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.