[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: lexical and dynamic binding
From: |
Arash Esbati |
Subject: |
Re: lexical and dynamic binding |
Date: |
Thu, 28 Oct 2021 12:58:53 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 |
Ikumi Keita <ikumi@ikumi.que.jp> writes:
>>>>>> Ikumi Keita <ikumi@ikumi.que.jp> writes:
>> My understanding of the last sentence is as follows:
> More straightforwad example is:
> ----------------------------------------------------------------------
> (setq foo 1) ; dynamic global binding without defvar.
> (let ((foo foo)) ; creates lexical binding on foo.
> (setq foo (1+ foo)) ; sets lexically bound value.
> (symbol-value 'foo)) ; accesses dynamically bound value.
> ; => 1
> ----------------------------------------------------------------------
> This is the meaning of
> ,----
> | Note that if ‘lexical-binding’ is in effect, this returns the
> | global value outside of any lexical scope.
> `----
> , I think.
I think you're right. This example:
--8<---------------cut here---------------start------------->8---
(setq foo 1) ; dynamic global binding without defvar.
(let (_)
(defvar foo) ; Mark foo as special
(let ((foo foo)) ; creates lexical binding on foo.
(setq foo (1+ foo)) ; sets lexically bound value.
(symbol-value 'foo))) ; accesses dynamically bound value.
; => 2
--8<---------------cut here---------------end--------------->8---
marks foo as special and symbol-value returns the value within the inner
let. I agree with Tassilo that the docs could be a bit more clear.
Best, Arash
- Extending TeX-read-key-val, Arash Esbati, 2021/10/22
- Re: Extending TeX-read-key-val, Ikumi Keita, 2021/10/23
- Re: Extending TeX-read-key-val, Arash Esbati, 2021/10/24
- Re: Extending TeX-read-key-val, Tassilo Horn, 2021/10/24
- Re: Extending TeX-read-key-val, Arash Esbati, 2021/10/27
- Re: Extending TeX-read-key-val, Tassilo Horn, 2021/10/28
- lexical and dynamic binding, Ikumi Keita, 2021/10/28
- Re: lexical and dynamic binding, Tassilo Horn, 2021/10/28
- Re: lexical and dynamic binding, Ikumi Keita, 2021/10/28
- Re: lexical and dynamic binding,
Arash Esbati <=
- Re: Extending TeX-read-key-val, Ikumi Keita, 2021/10/25