Ikumi Keita <ik...@ikumi.que.jp> writes:

>>>>>> Ikumi Keita <ik...@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

Reply via email to