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

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

Re: Passing optional arguments for use with internal functions


From: Emanuel Berg
Subject: Re: Passing optional arguments for use with internal functions
Date: Mon, 31 Jul 2023 14:27:09 +0200
User-agent: Gnus/5.13 (Gnus v5.13)

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 via email to

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