all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Emanuel Berg <incal@dataswamp.org>
To: help-gnu-emacs@gnu.org
Subject: Re: Passing optional arguments for use with internal functions
Date: Mon, 31 Jul 2023 14:27:09 +0200	[thread overview]
Message-ID: <87y1iwe06a.fsf@dataswamp.org> (raw)
In-Reply-To: xWtYxR0YqJPtIpVTTOHZQOOon-ZASO0giqGMIxi7PvtwwdW4XYHssFCT6uvhOkcdnGd21cGx8p5kY1xpPLduXCVZzx3UPILS27udohCb0Zk=@proton.me

uzibalqa wrote:

>> ;;; -- lexical-binding: nil --
>> 
>> (defvar arg)
>> (setq arg 2)
>> 
>> (defun echo-arg (&optional arg)
>> (or arg (setq arg 1))
>> (message "%s" arg) )
>> 
>> ;; (echo-arg)
>> 
>> This will still echo 1.
>
> Now that there has been a change from dynamic to lexical
> binding, this becomes a problem. What command should one use
> to set a default value to an optional argument for the
> current lexical binding files ?

The same, since function arguments are always lexical.

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




  reply	other threads:[~2023-07-31 12:27 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 [this message]
2023-08-02 18:01           ` uzibalqa
2023-08-02 18:20             ` Emanuel Berg
2023-08-02 19:24               ` uzibalqa
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

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

  git send-email \
    --in-reply-to=87y1iwe06a.fsf@dataswamp.org \
    --to=incal@dataswamp.org \
    --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.