unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: uzibalqa <uzibalqa@proton.me>
To: Emanuel Berg <incal@dataswamp.org>
Cc: help-gnu-emacs@gnu.org
Subject: Re: Passing optional arguments for use with internal functions
Date: Wed, 02 Aug 2023 19:24:00 +0000	[thread overview]
Message-ID: <dgF4wOmMT49AXwWjXcFj61dHglJQWTtwaY5KIz2i4feHZwBH9-M1diAqDKy27XW_1BTc5uqvu8FfBG-kSh36mM8cwE3EJKEFmxxdOGUk-sM=@proton.me> (raw)
In-Reply-To: <87leetl30m.fsf@dataswamp.org>






Sent with Proton Mail secure email.

------- Original Message -------
On Thursday, August 3rd, 2023 at 6:20 AM, Emanuel Berg <incal@dataswamp.org> wrote:


> uzibalqa wrote:
> 
> > To be absolutely sure I understand. If I want to default
> > a function optional argument if it is not used, the command
> > to that that is
> > 
> > (defun dothis x ()
> > (or x (setq x 8)) ; [...]
> > (do-something x)
> > )
> > 
> > And this would always work. In will work if I use the
> > lexical-binding directive at the top of a file. And it would
> > work if I use dynamic-binding directive at the top of
> > a file.
> 
> 
> Correct, as that wouldn't affect them because function formal
> parameters (the argument placeholders) are always under
> lexical/static scope.
> 
> > Calling the command (dothis) will always use x with value 8,
> > and executing (do-something 8) .
> 
> 
> Yes, you forgot about the &optional keyword in your example
> but other than that it is correct.

Right, it should have been  (defun dothis (&optional x)


 
> --
> underground experts united
> https://dataswamp.org/~incal



  reply	other threads:[~2023-08-02 19:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-27 23:45 Passing optional arguments for use with internal functions uzibalqa
2023-07-28 10:51 ` Emanuel Berg
2023-07-28 16:42   ` Heime
2023-07-28 17:11     ` Emanuel Berg
2023-07-30 16:09       ` uzibalqa
2023-07-31 12:27         ` Emanuel Berg
2023-08-02 18:01           ` uzibalqa
2023-08-02 18:20             ` Emanuel Berg
2023-08-02 19:24               ` uzibalqa [this message]
2023-08-02 19:53                 ` uzibalqa
2023-08-02 23:24                   ` Emanuel Berg
2023-08-03 15:25                   ` Emanuel Berg
2023-08-03 15:35                   ` Emanuel Berg
2023-08-03 15:46                   ` Emanuel Berg
2023-07-28 20:02   ` [External] : " Drew Adams
2023-07-28 20:42     ` uzibalqa

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to='dgF4wOmMT49AXwWjXcFj61dHglJQWTtwaY5KIz2i4feHZwBH9-M1diAqDKy27XW_1BTc5uqvu8FfBG-kSh36mM8cwE3EJKEFmxxdOGUk-sM=@proton.me' \
    --to=uzibalqa@proton.me \
    --cc=help-gnu-emacs@gnu.org \
    --cc=incal@dataswamp.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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).